diff --git a/VERSIONS_WIP/50471 b/VERSIONS_WIP/50471 new file mode 100644 index 0000000000000000000000000000000000000000..eeb1f4fe41fbe2cdceb0a1200171283d51c2792f --- /dev/null +++ b/VERSIONS_WIP/50471 @@ -0,0 +1 @@ +- ticket #50471 : ajout d'un sélecteur de domaines dans la boîte de recherche simple \ No newline at end of file diff --git a/library/Class/CodifThesaurus.php b/library/Class/CodifThesaurus.php index c42b55c3222769643b7ca1c529bfcc371a180259..2be4f8956f5ed8d15a3f6286eaaed2812109eac8 100644 --- a/library/Class/CodifThesaurus.php +++ b/library/Class/CodifThesaurus.php @@ -32,6 +32,7 @@ class CodifThesaurusLoader extends Storm_Model_Loader { public function findThesaurusForCatalogue($catalogue_id) { + xdebug_break(); return Class_CodifThesaurus::getLoader() ->findFirstBy(['id_origine'=> $catalogue_id, 'code' => Class_CodifThesaurus::fixedCodeOf('Domain')]); diff --git a/library/Class/Systeme/ModulesAccueil/RechercheSimple.php b/library/Class/Systeme/ModulesAccueil/RechercheSimple.php index 315f52e33c547d810b000f12b48f1a1212497e7e..beab0248ab3aae138189fa017f018c9cf79b8215 100644 --- a/library/Class/Systeme/ModulesAccueil/RechercheSimple.php +++ b/library/Class/Systeme/ModulesAccueil/RechercheSimple.php @@ -52,7 +52,8 @@ class Class_Systeme_ModulesAccueil_RechercheSimple extends Class_Systeme_Modules 'tri' => '*', 'profil_redirect' => 0, //type de profil vers lequel basculer lors d'une recherche 'placeholder' => '', //message d'exemple dans le champ de recherche - 'search_button' => ''//search button text value + 'search_button' => '', //search button text value, + 'domain_ids' => '' // list of domains user can choose to restrict search ]; } ?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/TagRechercheSimple.php b/library/ZendAfi/View/Helper/TagRechercheSimple.php index b9599aac203ecf478b9520f2246340e408b1b790..17f741d483575769ed1b605bca4802501288ba57 100644 --- a/library/ZendAfi/View/Helper/TagRechercheSimple.php +++ b/library/ZendAfi/View/Helper/TagRechercheSimple.php @@ -147,7 +147,7 @@ class ZendAfi_View_Helper_TagRechercheSimple extends Zend_View_Helper_HtmlElemen public function renderDomainSelect() { - $domain_ids = array_filter(explode('-', trim($this->preferences['domain_ids']))); + $domain_ids = array_filter(explode('-', trim($this->preferences['domain_ids'])), 'is_numeric'); if (!$domain_ids) return ''; diff --git a/tests/application/modules/admin/controllers/AccueilControllerTest.php b/tests/application/modules/admin/controllers/AccueilControllerTest.php index f1a90dc463a3ec191a2255fe3b61f882e4f07db3..3e54432e1eb52ddd5893040cae81ae9959f03bc8 100644 --- a/tests/application/modules/admin/controllers/AccueilControllerTest.php +++ b/tests/application/modules/admin/controllers/AccueilControllerTest.php @@ -822,7 +822,8 @@ abstract class AccueilControllerRechSimpleConfigurationTestCase extends Admin_Ab 'id_module' => 2, 'preferences' => ['titre' => 'Recherchez', 'boite' => 'boite_vide', - 'placeholder' => 'ex: Potter']]; + 'placeholder' => 'ex: Potter', + 'domain_ids' => '4']]; $this->_profil_adulte = Class_Profil::getCurrentProfil() ->setLibelle('Adulte') @@ -898,6 +899,7 @@ class AccueilControllerRechSimpleConfigurationTest extends AccueilControllerRech ->answers([$this->_profil_adulte, Class_Profil::newInstanceWithId(98, ['libelle' => 'Jeunesse'])]); + $this->request_url = '/admin/accueil/rechsimple?id_module=2&type_module=RECH_SIMPLE&config=accueil'; $this->dispatch($this->request_url, true); } @@ -948,6 +950,15 @@ class AccueilControllerRechSimpleConfigurationTest extends AccueilControllerRech } + /** @test */ + public function domainSelectorShouldBePresent() { + $this->assertXPath('//input[@name="domain_ids"][@value="4"]'); + } + + /** @test */ + public function domainSelectorScriptShouldBeLoaded() { + $this->assertXPathContentContains('//script', '$.getJSON("/abonne/viewable-domains-json"'); + } } diff --git a/tests/library/ZendAfi/View/Helper/TagRechercheSimpleTest.php b/tests/library/ZendAfi/View/Helper/TagRechercheSimpleTest.php index 47210c9b6d33da0e7cf53b4f36801479598ef26a..ad2abe667a8b8cf04e3c9c67b95584da2c53086b 100644 --- a/tests/library/ZendAfi/View/Helper/TagRechercheSimpleTest.php +++ b/tests/library/ZendAfi/View/Helper/TagRechercheSimpleTest.php @@ -72,10 +72,76 @@ class ZendAfi_View_Helper_TagRechercheSimpleDefaultTest extends ViewHelperTestCa $html = $this->_helper->tagRechercheSimple($this->_preferences, 1); $this->assertXPath($html, '//form//input[@name="expressionRecherche"][@placeholder="ex: Nineteen Eighty Four"]'); } + + + /** @test */ + public function withoutDomainPreferencesMultifacetCheckboxShouldNotBeIncluded() { + $html = $this->_helper->tagRechercheSimple($this->_preferences, 1); + $this->assertNotXPath($html, '//input[contains(@name, "multifacet")]'); + } + + + /** @test */ + public function withDomainPreferencesMultifacetCheckboxShouldBePresent() { + Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Catalogue') + ->whenCalled('saveThesaurus') + ->answers(null); + $this->fixture('Class_Catalogue', + ['id' => 4, + 'libelle' => 'Adults']); + + $this->fixture('Class_Catalogue', + ['id' => 5, + 'libelle' => 'Youths']); + + $this->fixture('Class_CodifThesaurus', + ['id' => 4, + 'id_thesaurus' => 'CCCC0004', + 'id_origine' => 4, + 'code' => 'Catalogue', + 'libelle' => 'Adults']); + + $this->fixture('Class_CodifThesaurus', + ['id' => 5, + 'id_thesaurus' => 'CCCC0005', + 'id_origine' => 5, + 'code' => 'Catalogue', + 'libelle' => 'Youth']); + + $this->_preferences['domain_ids'] = 'a-4-5-b 1-'; + $html = $this->_helper->tagRechercheSimple($this->_preferences, 1); + $this->assertXPathCount($html, '//input[@type="checkbox"][contains(@name, "multifacet")]', + 2); + return $html; + } + + + /** + * @depends withDomainPreferencesMultifacetCheckboxShouldBePresent + * @test + */ + public function multifaceHCCCC0004ShouldBePresent($html) { + $this->assertXPathContentContains($html, + '//label[preceding-sibling::input[@name="multifacet_HCCCC0004"]]', + 'Adult'); + } + + + /** + * @depends withDomainPreferencesMultifacetCheckboxShouldBePresent + * @test + */ + public function multifaceHCCCC0005ShouldBePresent($html) { + $this->assertXPathContentContains($html, + '//label[preceding-sibling::input[@name="multifacet_HCCCC0005"]]', + 'Youth', + $html); + } } + class ZendAfi_View_Helper_TagRechercheSimpleWithSessionParamsTest extends ViewHelperTestCase { protected $_session;