diff --git a/application/modules/opac/controllers/SitoController.php b/application/modules/opac/controllers/SitoController.php index 22e054e4e966437635aea25b291d9f3fd909e9db..a86fbc8bcfcd322fa32b5bde8a904b398e7215f2 100644 --- a/application/modules/opac/controllers/SitoController.php +++ b/application/modules/opac/controllers/SitoController.php @@ -63,14 +63,13 @@ class SitoController extends Zend_Controller_Action { function viewselectionAction() { - $class_sito = new Class_Sitotheque(); $id_module = $this->_request->getParam('id_module'); $preferences = Class_Profil::getCurrentProfil()->getModuleAccueilPreferences($id_module); - $sites = $class_sito->getSitesFromIdsAndCategories( - explode('-',$preferences['id_items']), - explode("-",$preferences['id_categorie'])); + $sites = Class_Sitotheque::getLoader()->getSitesFromIdsAndCategories( + explode('-',$preferences['id_items']), + explode('-',$preferences['id_categorie'])); $this->view->sites = $sites; $this->view->title = $this->view->_("Sélection de sites"); } diff --git a/library/Class/Sitotheque.php b/library/Class/Sitotheque.php index efb6095081dc47e1bb3117297d0d7fd1afa4b525..9bcb79138ee6fa5bef499e2cb7f182ac6f2856ce 100644 --- a/library/Class/Sitotheque.php +++ b/library/Class/Sitotheque.php @@ -249,7 +249,7 @@ class Class_Sitotheque extends Storm_Model_Abstract { $sites = array_merge($sites, $sites_in_cat); } - return $sites; + return array_filter($sites); } diff --git a/tests/application/modules/opac/controllers/SitoControllerTest.php b/tests/application/modules/opac/controllers/SitoControllerTest.php index 65aae3b4daacb4c4b4ce8872d650e5ab4156af66..5d92bfa01bdf3a91249828a1792c1bef7a128d6f 100644 --- a/tests/application/modules/opac/controllers/SitoControllerTest.php +++ b/tests/application/modules/opac/controllers/SitoControllerTest.php @@ -33,13 +33,23 @@ class SitoControllerViewViewSelectionTest extends AbstractControllerTestCase { 'description' => 'Pour tous les linuxiens', 'url' => 'http://linuxfr.org']); + + $this->fixture('Class_Sitotheque', + ['id' => 28, + 'id_cat' => 0, + 'titre' => 'Hurd', + 'description' => 'Pour tous les Gnus', + 'url' => 'http://hurd.gnu.org']); + + Class_Profil::getCurrentProfil() ->setCfgAccueil([ 'modules' => [ '1' => [ 'division' => '2', 'type_module' => 'SITO', - 'preferences' => ['id_categorie' => '3'] + 'preferences' => ['id_categorie' => '3', + 'id_items' => '25-28'] ] ], 'options' => []]); @@ -51,7 +61,14 @@ class SitoControllerViewViewSelectionTest extends AbstractControllerTestCase { /** @test */ public function siteLinuxFrShouldBeVisible() { $this->assertXPath('//div[@class="contenu"]//div[@class="sitotheque"]//a[@href="http://linuxfr.org"]', - 'LinuxFr'); + $this->_response->getBody()); + } + + + /** @test */ + public function siteHurdDotOrgShouldBeVisible() { + $this->assertXPath('//div[@class="contenu"]//div[@class="sitotheque"]//a[@href="http://hurd.gnu.org"]', + $this->_response->getBody()); }