Skip to content
Snippets Groups Projects
Commit 83164fc7 authored by Ghislain Loas's avatar Ghislain Loas
Browse files

Merge branch 'hotline#74120_pb_parametrage_boite_recherche_types_doc_par_defaut_ko' into 'hotline'

hotline #74120 fix doc type selector in search widget

See merge request !2604
parents bda2fb16 8166584f
Branches
Tags
2 merge requests!2660Master,!2604hotline #74120 fix doc type selector in search widget
Pipeline #3934 passed with stage
in 35 minutes
- ticket #74120 : Boite de recherche : correction de la prise en compte du type de document par défaut.
\ No newline at end of file
......@@ -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) {
......
......@@ -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']);
......
......@@ -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;
......
......@@ -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
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment