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..f83532dd0f2a2b59153231f7640aa74529d404b7 100644 --- a/library/ZendAfi/View/Helper/ComboCodification.php +++ b/library/ZendAfi/View/Helper/ComboCodification.php @@ -24,9 +24,12 @@ class ZendAfi_View_Helper_ComboCodification extends ZendAfi_View_Helper_BaseHelp const SECTION = 'section'; public function ComboCodification($type, $valeur_select, $events = '') { - if(!$valeur_select) + if(null === $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/library/digital_resources/StoryPlayR/tests/StoryPlayRTest.php b/library/digital_resources/StoryPlayR/tests/StoryPlayRTest.php index ed2a892e867cbf56334d7d23b59a6a7b39a67896..e09d43336270777b047cdde42acada85dd0ac7d9 100644 --- a/library/digital_resources/StoryPlayR/tests/StoryPlayRTest.php +++ b/library/digital_resources/StoryPlayR/tests/StoryPlayRTest.php @@ -19,7 +19,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -class StoryPlayRActivatedTestCase extends AbstractControllerTestCase { +abstract class StoryPlayRActivatedTestCase extends AbstractControllerTestCase { protected $_storm_default_to_volatile = true, $_user; diff --git a/tests/library/ZendAfi/View/Helper/TagRechercheSimpleTest.php b/tests/library/ZendAfi/View/Helper/TagRechercheSimpleTest.php index 84cfe63a079c2a1143517a5b817b8127ffe118ad..c5292c70bd17ad3e2c069c11c4099d0c243dd9cd 100644 --- a/tests/library/ZendAfi/View/Helper/TagRechercheSimpleTest.php +++ b/tests/library/ZendAfi/View/Helper/TagRechercheSimpleTest.php @@ -352,4 +352,69 @@ 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'); + $this->assertXPathContentContains($this->_html, '//option[@value="0"][not(@selected)]', 'Non identifi'); + } + + + /** @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'); + $this->assertXPathContentContains($this->_html, '//option[@value=""][not(@selected)]', 'tous'); + } } \ No newline at end of file