From 13bd7fea0ada6247ebf1fbb25dfa966cd2aef9d0 Mon Sep 17 00:00:00 2001
From: gloas <gloas@afi-sa.fr>
Date: Mon, 28 May 2018 09:50:47 +0200
Subject: [PATCH] dev #75659 add test button in catalog edit form

---
 VERSIONS_WIP/75659                               |  2 ++
 .../admin/views/scripts/catalogue/form.phtml     | 16 +++++++++++++++-
 .../controllers/CatalogueControllerTest.php      | 10 ++++++++--
 3 files changed, 25 insertions(+), 3 deletions(-)
 create mode 100644 VERSIONS_WIP/75659

diff --git a/VERSIONS_WIP/75659 b/VERSIONS_WIP/75659
new file mode 100644
index 00000000000..0a74c273aad
--- /dev/null
+++ b/VERSIONS_WIP/75659
@@ -0,0 +1,2 @@
+ - ticket #75659 : Administration : ajout du bouton tester dans le formulaire de modification d'un domaine.
+ 
\ No newline at end of file
diff --git a/application/modules/admin/views/scripts/catalogue/form.phtml b/application/modules/admin/views/scripts/catalogue/form.phtml
index c52ca489f90..42effded8e2 100644
--- a/application/modules/admin/views/scripts/catalogue/form.phtml
+++ b/application/modules/admin/views/scripts/catalogue/form.phtml
@@ -1 +1,15 @@
-<?php echo $this->renderForm($this->form); ?>
+<?php
+if(!$this->catalogue->isNew())
+  echo $this->tag('div',
+                  $this->tagAnchor($this->url(['action' => 'tester',
+                                               'id_catalogue' => $this->catalogue->getId()]),
+                                   Class_Admin_Skin::current()
+                                        ->renderActionIconOn('test',
+                                                             $this,
+                                                             ['alt' => $this->_('Tester'),
+                                                              'title' => $this->_('Tester le catalogue "%s"',
+                                                                                  $this->catalogue->getLibelle())]),
+                                   ['data-popup' => true]),
+                  ['class' => 'header_actions']);
+
+echo $this->renderForm($this->form);
diff --git a/tests/application/modules/admin/controllers/CatalogueControllerTest.php b/tests/application/modules/admin/controllers/CatalogueControllerTest.php
index efb85b730d6..49a7d8076e0 100644
--- a/tests/application/modules/admin/controllers/CatalogueControllerTest.php
+++ b/tests/application/modules/admin/controllers/CatalogueControllerTest.php
@@ -270,7 +270,7 @@ class CatalogueControllerWithAdminBibAndRightTotalAccessTest extends AdminCatalo
 
   /** @test */
   public function editCatalogueShouldShowValiderButton() {
-    $this->dispatch('/admin/catalogue/edit/id_catalogue/300');
+    $this->dispatch('/admin/catalogue/edit/id_catalogue/300', true);
     $this->assertXPathContentContains('//button', 'Valider');
   }
 
@@ -785,6 +785,12 @@ class CatalogueControllerEditCatalogueTest extends AdminCatalogueControllerTestC
   public function shouldNotContainsAnnexeNoveltyThesaurus() {
     $this->assertNotXPath('//input[@name="NANA"]');
   }
+
+
+  /** @test */
+  public function shouldContainsPopupLinkToTestAction() {
+    $this->assertXPath('//a[contains(@href, "/tester/id_catalogue/6")][@data-popup]');
+  }
 }
 
 
@@ -1737,4 +1743,4 @@ class Admin_CatalogueControllerActionDomainesTestCase extends AbstractController
     $this->dispatch('/admin/catalogue/domaines', true);
     $this->assertNotRedirect();
   }
-}
+}
\ No newline at end of file
-- 
GitLab