diff --git a/VERSIONS_HOTLINE/74120 b/VERSIONS_HOTLINE/74120 new file mode 100644 index 0000000000000000000000000000000000000000..16f17e835a47e0d9f952acc6ccf872e6a25c63a7 --- /dev/null +++ b/VERSIONS_HOTLINE/74120 @@ -0,0 +1,2 @@ + - ticket #74120 : Boite de recherche : correction de la prise en compte du type de document par défaut. + \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/ComboCodification.php b/library/ZendAfi/View/Helper/ComboCodification.php index 1f294c164ce26b76a9222f2240b3369f9a2b7eec..b42e14e2df6a65e888beeaf8d94c18070ef6e479 100644 --- a/library/ZendAfi/View/Helper/ComboCodification.php +++ b/library/ZendAfi/View/Helper/ComboCodification.php @@ -27,6 +27,9 @@ class ZendAfi_View_Helper_ComboCodification extends ZendAfi_View_Helper_BaseHelp if(!$valeur_select) $valeur_select = []; + if(!is_array($valeur_select)) + $valeur_select = [$valeur_select]; + $profil = Class_Profil::getCurrentProfil(); if (self::TYPE_DOC == $type) { diff --git a/library/ZendAfi/View/Helper/TagRechercheSimple.php b/library/ZendAfi/View/Helper/TagRechercheSimple.php index d8c095a53a0606558e2591eb9308503a7bfee78a..b4122c16d126f1acba9cfff271efc749216f8c2b 100644 --- a/library/ZendAfi/View/Helper/TagRechercheSimple.php +++ b/library/ZendAfi/View/Helper/TagRechercheSimple.php @@ -247,16 +247,16 @@ class ZendAfi_View_Helper_TagRechercheSimple extends Zend_View_Helper_HtmlElemen } -//--------------------------------------------------------------------- -// Combo des types de documents -//--------------------------------------------------------------------- + public function getComboTypesDocs() { - return $this->view->ComboCodification('type_doc', ''); + $doc_type = array_key_exists('type_doc' , $this->preferences) + ? $this->preferences['type_doc'] + : null; + + return $this->view->ComboCodification('type_doc', $doc_type); } -//--------------------------------------------------------------------- -// Combo des annexes -//--------------------------------------------------------------------- + public function getComboAnnexes() { $combo = ''; $annexes = Class_CodifAnnexe::findAllBy(['invisible' => 0, 'order' => 'libelle']); diff --git a/tests/library/ZendAfi/View/Helper/TagRechercheSimpleTest.php b/tests/library/ZendAfi/View/Helper/TagRechercheSimpleTest.php index 84cfe63a079c2a1143517a5b817b8127ffe118ad..7eb283b3dffd242cf6d23e72b9fae831d55d8a80 100644 --- a/tests/library/ZendAfi/View/Helper/TagRechercheSimpleTest.php +++ b/tests/library/ZendAfi/View/Helper/TagRechercheSimpleTest.php @@ -352,4 +352,67 @@ class ZendAfi_View_Helper_TagRechercheSimpleAdvancedSearchTest '//a[contains(@href, "/recherche/avancee/statut/reset")]', utf8_encode('Recherche avancée')); } +} + + + + + +class ZendAfi_View_Helper_TagRechercheSimpleDocTypeTest extends ZendAfi_View_Helper_TagRechercheSimpleTestCase { + + + public function setUp() { + parent::setUp(); + $this->fixture('Class_CosmoVar', + ['id' => 'types_docs', + 'liste' => "0:non identifié\r\n1:Livres\r\n2:périodiques"]); + $adapter = $this->mock() + ->whenCalled('fetchAll') + ->answers([['type_doc' => '0'], + ['type_doc' => '1'], + ['type_doc' => '2']]); + + $table = $this->mock() + ->whenCalled('getAdapter') + ->answers($adapter); + + $this->onLoaderOfModel('Class_Notice') + ->whenCalled('getTable') + ->answers($table); + + $this->preferences['select_doc'] = '1'; + $this->preferences['tri'] = '*'; + $this->preferences['message'] = ''; + $this->preferences['placeholder'] = ''; + $this->preferences['largeur'] = ''; + $this->preferences['exemple'] = ''; + $this->preferences['select_annexe'] = ''; + $this->preferences['domain_ids'] = ''; + $this->preferences['select_bib'] = ''; + $this->preferences['recherche_avancee'] = ''; + } + + + /** @test */ + public function tousShouldBeSelected() { + $this->preferences['type_doc'] = ''; + $this->_html = $this->_helper->tagRechercheSimple($this->preferences, 1); + $this->assertXPathContentContains($this->_html, '//option[@value=""][@selected]', 'tous'); + } + + + /** @test */ + public function livresShouldBeSelected() { + $this->preferences['type_doc'] = '1'; + $this->_html = $this->_helper->tagRechercheSimple($this->preferences, 1); + $this->assertXPathContentContains($this->_html, '//option[@value="1"][@selected]', 'Livres'); + } + + + /** @test */ + public function nonIdentifieShouldBeSelected() { + $this->preferences['type_doc'] = '0'; + $this->_html = $this->_helper->tagRechercheSimple($this->preferences, 1); + $this->assertXPathContentContains($this->_html, '//option[@value="0"][@selected]', 'Non identifi'); + } } \ No newline at end of file