diff --git a/library/Class/TypeDoc.php b/library/Class/TypeDoc.php index f7eeb56e930ca3261f18b61b3758e861f55b9fec..df315bedae228e6db52ed840b2861e9dd6535e11 100644 --- a/library/Class/TypeDoc.php +++ b/library/Class/TypeDoc.php @@ -158,16 +158,16 @@ class TypeDocLoader extends Storm_Model_Loader { protected function _saveSerialized($serialized) { $this->reset(); - return Class_CosmoVar::getLoader() - ->find('types_docs') + return Class_CosmoVar::find('types_docs') ->setListe(implode("\r\n", $serialized)) ->save(); } public function findUsedTypeDocIds() { - $rows = Class_Notice::getTable()->getAdapter() - ->fetchAll('select distinct(type_doc) from notices'); + $rows = Class_Notice::getTable() + ->getAdapter() + ->fetchAll('select distinct(type_doc) from notices'); return array_map(function($row){return $row['type_doc'];}, $rows); } diff --git a/tests/application/modules/opac/controllers/RechercheControllerTest.php b/tests/application/modules/opac/controllers/RechercheControllerTest.php index 66402dfb0a309bcad13f59802babaef986297cd7..1f3c76df0d17ec0f907ee90c2dc5333aa117d47e 100644 --- a/tests/application/modules/opac/controllers/RechercheControllerTest.php +++ b/tests/application/modules/opac/controllers/RechercheControllerTest.php @@ -2620,25 +2620,32 @@ class RechercheControllerNavigationTest extends RechercheControllerNoticeTestCas class RechercheControllerAvanceeTest extends AbstractControllerTestCase { + protected $_storm_default_to_volatile = true; public function setUp() { parent::setUp(); - Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Notice') + $this->fixture('Class_CosmoVar', + ['id' => 'types_docs', + 'liste' => '0:non identifié\r\n1:livre\r\n2:article']); + + Storm_Test_ObjectWrapper::onLoaderOfModel('Class_TypeDoc') ->whenCalled('findUsedTypeDocIds') - ->answers([1, 2, 'Assimil']); + ->answers([1, 2, 'Assimil']) - $this->fixture('Class_TypeDoc', - ['id' => 1, - 'label' => 'Livre']); + ->whenCalled('findAll') + ->answers([$this->fixture('Class_TypeDoc', + ['id' => 1, + 'label' => 'Livre']), - $this->fixture('Class_TypeDoc', - ['id' => 2, - 'label' => 'Article']); + $this->fixture('Class_TypeDoc', + ['id' => 2, + 'label' => 'Article']), - $this->fixture('Class_TypeDoc', - ['id' => 'Assimil', - 'label' => 'Langue']); + $this->fixture('Class_TypeDoc', + ['id' => 'Assimil', + 'label' => 'Langue']) + ]); $this->dispatch('/recherche/avancee', true); } @@ -2675,14 +2682,20 @@ class RechercheControllerAvanceeTest extends AbstractControllerTestCase { /** @test */ - public function typeDocInuptShouldHaveSecondOptionOnArticle() { + public function typeDocInuptShouldHaveOptionBook() { + $this->assertXPathContentContains('//select[@name="type_doc"]/option[4][@value="1"]', 'Livre'); + } + + + /** @test */ + public function typeDocInuptShouldHaveOptionArticle() { $this->assertXPathContentContains('//select[@name="type_doc"]/option[2]', 'Article'); } /** @test */ public function assimilShouldNotBeSelected() { - $this->assertXPathContentContains('//select[@name="type_doc"]/option[@value="Assimil"][not(@selected)]', 'Langue'); + $this->assertXPathContentContains('//select[@name="type_doc"]/option[3][@value="Assimil"][not(@selected)]', 'Langue'); } }