diff --git a/VERSIONS_HOTLINE/52528 b/VERSIONS_HOTLINE/52528 new file mode 100644 index 0000000000000000000000000000000000000000..9464cb05cba58345e672c787b9462eb36c2077e0 --- /dev/null +++ b/VERSIONS_HOTLINE/52528 @@ -0,0 +1 @@ + - ticket #52528 : Correction affichage du lien vers la recherche avancée dans la boite de recherche simple \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/TagRechercheSimple.php b/library/ZendAfi/View/Helper/TagRechercheSimple.php index 64915c5f866b4cd66f2bae047f3753fab8e4ba75..d8c095a53a0606558e2591eb9308503a7bfee78a 100644 --- a/library/ZendAfi/View/Helper/TagRechercheSimple.php +++ b/library/ZendAfi/View/Helper/TagRechercheSimple.php @@ -42,7 +42,7 @@ class ZendAfi_View_Helper_TagRechercheSimple extends Zend_View_Helper_HtmlElemen public function renderRechercheAvancee() { - if (!in_array($this->preferences["recherche_avancee"], ['on', 1], true)) + if (!in_array($this->preferences["recherche_avancee"], ['on', 1, '1'], true)) return ''; return '<div class="recherche_avancee">'. diff --git a/tests/library/ZendAfi/View/Helper/TagRechercheSimpleTest.php b/tests/library/ZendAfi/View/Helper/TagRechercheSimpleTest.php index fdd6a40b1a17286a69f41d12486057de60a71614..84cfe63a079c2a1143517a5b817b8127ffe118ad 100644 --- a/tests/library/ZendAfi/View/Helper/TagRechercheSimpleTest.php +++ b/tests/library/ZendAfi/View/Helper/TagRechercheSimpleTest.php @@ -19,42 +19,42 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -require_once('ViewHelperTestCase.php'); - -class ZendAfi_View_Helper_TagRechercheSimpleDefaultTest extends ViewHelperTestCase { - /** @var ZendAfi_View_Helper_TagRechercheSimple */ - protected $_helper; - - /** @var Class_Album */ - protected $_album; - - /** @var array */ - protected $_preferences = null; +abstract class ZendAfi_View_Helper_TagRechercheSimpleTestCase extends ViewHelperTestCase { + protected + $_storm_default_to_volatile = true, + $_helper, + $_preferences; public function setUp() { parent::setUp(); + + $this->onLoaderOfModel('Class_Catalogue') + ->whenCalled('saveThesaurus') + ->answers(null); + $view = new ZendAfi_Controller_Action_Helper_View(); $this->_helper = new ZendAfi_View_Helper_TagRechercheSimple(); $this->_helper->setView($view); $this->_preferences = (new Class_Systeme_ModulesAccueil_RechercheSimple())->getDefaultValues(); - $this->_preferences['placeholder'] = 'ex: Nineteen Eighty Four'; } +} - /** @test */ - public function withoutTypeDocAndProfilRedirectActionShouldBeRechercheSimpleWithoutMoreParams() { - $html = $this->_helper->tagRechercheSimple($this->_preferences, 1); - $this->assertNotXPath($html, '//form[contains(@action, "/simple/")]', $html); + +class ZendAfi_View_Helper_TagRechercheSimpleDefaultTest + extends ZendAfi_View_Helper_TagRechercheSimpleTestCase { + + public function setUp() { + parent::setUp(); + $this->_preferences['placeholder'] = 'ex: Nineteen Eighty Four'; } /** @test */ - public function rechercheAvanceeShouldBeVisible() { + public function withoutTypeDocAndProfilRedirectActionShouldBeRechercheSimpleWithoutMoreParams() { $html = $this->_helper->tagRechercheSimple($this->_preferences, 1); - $this->assertXPathContentContains($html, - '//a[contains(@href, "/recherche/avancee/statut/reset")]', - utf8_encode('Recherche avancée')); + $this->assertNotXPath($html, '//form[contains(@action, "/simple/")]', $html); } @@ -83,32 +83,26 @@ class ZendAfi_View_Helper_TagRechercheSimpleDefaultTest extends ViewHelperTestCa /** @test */ public function withDomainSelectInputShouldBePresent() { - $this->fixture('Class_Catalogue', - ['id' => 4, - 'libelle' => 'Youths']); - - $this->fixture('Class_Catalogue', - ['id' => 5, - 'libelle' => 'Adults']); + $this->fixture('Class_Catalogue', ['id' => 4, 'libelle' => 'Youths']); + $this->fixture('Class_Catalogue', ['id' => 5, 'libelle' => 'Adults']); $this->fixture('Class_CodifThesaurus', ['id' => 4, - 'id_thesaurus' => 'CCCC0004', + 'id_thesaurus' => 'CCCC0001', 'id_origine' => 4, 'code' => 'Catalogue', 'libelle' => 'Youths']); $this->fixture('Class_CodifThesaurus', ['id' => 5, - 'id_thesaurus' => 'CCCC0005', + 'id_thesaurus' => 'CCCC0002', 'id_origine' => 5, 'code' => 'Catalogue', 'libelle' => 'Adults']); $this->_preferences['domain_ids'] = 'a-4-5-b 1-'; $html = $this->_helper->tagRechercheSimple($this->_preferences, 1); - $this->assertXPathCount($html, '//select[@name="facettes"]//option', - 3); + $this->assertXPathCount($html, '//select[@name="facettes"]//option', 3); return $html; } @@ -130,7 +124,7 @@ class ZendAfi_View_Helper_TagRechercheSimpleDefaultTest extends ViewHelperTestCa */ public function domainSelectSecondOptionShouldBeAdults($html) { $this->assertXPathContentContains($html, - '//select[@name="facettes"]/option[2][@value="HCCCC0005"]', + '//select[@name="facettes"]/option[2][@value="HCCCC0002"][@label="Adults"]', 'Adults'); } @@ -141,7 +135,7 @@ class ZendAfi_View_Helper_TagRechercheSimpleDefaultTest extends ViewHelperTestCa */ public function domainSelectThirdOptionShouldBeYouths($html) { $this->assertXPathContentContains($html, - '//select[@name="facettes"]/option[3][@value="HCCCC0004"]', + '//select[@name="facettes"]/option[3][@value="HCCCC0001"][@label="Youths"]', 'Youths'); } } @@ -149,19 +143,15 @@ class ZendAfi_View_Helper_TagRechercheSimpleDefaultTest extends ViewHelperTestCa -class ZendAfi_View_Helper_TagRechercheSimpleWithSessionParamsTest extends ViewHelperTestCase { +class ZendAfi_View_Helper_TagRechercheSimpleWithSessionParamsTest + extends ZendAfi_View_Helper_TagRechercheSimpleTestCase { + protected $_session; public function setUp() { parent::setUp(); $this->_session = Zend_Registry::get('session'); - $view = new ZendAfi_Controller_Action_Helper_View(); - $this->_helper = new ZendAfi_View_Helper_TagRechercheSimple(); - $this->_helper->setView($view); - - $this->_preferences = (new Class_Systeme_ModulesAccueil_RechercheSimple())->getDefaultValues(); - $this->fixture('Class_Zone', ['id' => 1, @@ -171,7 +161,6 @@ class ZendAfi_View_Helper_TagRechercheSimpleWithSessionParamsTest extends ViewHe ['id' => 2, 'libelle' => 'Europe']); - $this->fixture('Class_Zone', ['id' => 3, 'libelle' => 'US']); @@ -212,9 +201,9 @@ class ZendAfi_View_Helper_TagRechercheSimpleWithSessionParamsTest extends ViewHe 'visibilite' => 2]); $this->_preferences['select_bib'] = '1'; - } + /** @test */ public function searchButtonWithNoValueShouldBeEmptyValue() { $html = $this->_helper->tagRechercheSimple($this->_preferences, 1); @@ -230,6 +219,7 @@ class ZendAfi_View_Helper_TagRechercheSimpleWithSessionParamsTest extends ViewHe } + /** @test */ public function withSelectionBibShouldPostExpectedValue() { $this->_session->id_bibs = [1,2,3]; @@ -288,9 +278,6 @@ class ZendAfi_View_Helper_TagRechercheSimpleWithSessionParamsTest extends ViewHe /** @test */ public function withDomainPreferencesMultifacetCheckboxShouldBePresent() { - Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Catalogue') - ->whenCalled('saveThesaurus') - ->answers(null); $this->fixture('Class_Catalogue', ['id' => 4, 'libelle' => 'Adults']); @@ -301,17 +288,18 @@ class ZendAfi_View_Helper_TagRechercheSimpleWithSessionParamsTest extends ViewHe $this->fixture('Class_CodifThesaurus', ['id' => 4, - 'id_thesaurus' => 'CCCC0004', + 'id_thesaurus' => 'CCCC0002', 'id_origine' => 4, 'code' => 'Catalogue', - 'libelle' => 'Adults']); + 'libelle' => 'Youths']); $this->fixture('Class_CodifThesaurus', ['id' => 5, - 'id_thesaurus' => 'CCCC0005', + 'id_thesaurus' => 'CCCC0001', 'id_origine' => 5, 'code' => 'Catalogue', - 'libelle' => 'Youth']); + 'libelle' => 'Adults']); + $this->_preferences['domain_ids'] = 'a-4-5-b 1-'; $this->_preferences['domain_select_style'] = Class_Systeme_ModulesAccueil_RechercheSimple::DOMAIN_SELECT_CHECKBOX; @@ -326,9 +314,9 @@ class ZendAfi_View_Helper_TagRechercheSimpleWithSessionParamsTest extends ViewHe * @depends withDomainPreferencesMultifacetCheckboxShouldBePresent * @test */ - public function multifaceHCCCC0004ShouldBePresent($html) { + public function multifaceHCCCC0001ShouldBePresent($html) { $this->assertXPathContentContains($html, - '//label[preceding-sibling::input[@name="multifacet_HCCCC0004"]]', + '//label[preceding-sibling::input[@name="multifacet_HCCCC0001"]]', 'Adult'); } @@ -337,11 +325,31 @@ class ZendAfi_View_Helper_TagRechercheSimpleWithSessionParamsTest extends ViewHe * @depends withDomainPreferencesMultifacetCheckboxShouldBePresent * @test */ - public function multifaceHCCCC0005ShouldBePresent($html) { + public function multifaceHCCCC0002ShouldBePresent($html) { $this->assertXPathContentContains($html, - '//label[preceding-sibling::input[@name="multifacet_HCCCC0005"]]', + '//label[preceding-sibling::input[@name="multifacet_HCCCC0002"]]', 'Youth', $html); } } -?> \ No newline at end of file + + + +class ZendAfi_View_Helper_TagRechercheSimpleAdvancedSearchTest + extends ZendAfi_View_Helper_TagRechercheSimpleTestCase { + + public function datas() { + return [ [1], ['on'], ['1'] ]; + } + + /** + * @test + * @dataProvider datas + */ + public function shouldBeVisibleFor($value) { + $this->_preferences['recherche_avancee'] = $value; + $this->assertXPathContentContains($this->_helper->tagRechercheSimple($this->_preferences, 1), + '//a[contains(@href, "/recherche/avancee/statut/reset")]', + utf8_encode('Recherche avancée')); + } +} \ No newline at end of file