From 7be41674f45b619bac3cff1a1bd1cf1e299e52a2 Mon Sep 17 00:00:00 2001 From: llaffont <laurent.laffont@gmail.com> Date: Thu, 20 Feb 2014 09:54:48 +0100 Subject: [PATCH] Fix website library display when a website is selecter in front widget but deleted --- .../opac/controllers/SitoController.php | 7 +++---- library/Class/Sitotheque.php | 2 +- .../opac/controllers/SitoControllerTest.php | 21 +++++++++++++++++-- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/application/modules/opac/controllers/SitoController.php b/application/modules/opac/controllers/SitoController.php index 22e054e4e96..a86fbc8bcfc 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 efb6095081d..9bcb79138ee 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 65aae3b4daa..5d92bfa01bd 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()); } -- GitLab