diff --git a/application/modules/opac/controllers/RssController.php b/application/modules/opac/controllers/RssController.php index a4113240d9ffbc691cdbf36a50fbf126ebee0dff..fab142f3a3cf1dbb125c2f65cb971430b433a606 100644 --- a/application/modules/opac/controllers/RssController.php +++ b/application/modules/opac/controllers/RssController.php @@ -353,15 +353,19 @@ class RssController extends Zend_Controller_Action function kiosqueAction() { $id_profil = (int)$this->_request->getParam('id_profil'); $id_module = (int)$this->_request->getParam('id_module'); - $profil = Class_Profil::getLoader()->find($id_profil); - $preferences = $profil->getModuleAccueilPreferences($id_module); + if (!$profil = Class_Profil::getLoader()->find($id_profil)) { + $notices = []; + $titre = 'Non trouvé'; + } else { + $preferences = $profil->getModuleAccueilPreferences($id_module); + $catalogue=new Class_Catalogue(); + $preferences["aleatoire"] = 0; // les dernières seulement + $notices = $catalogue->getNoticesByPreferences($preferences,"url"); + $titre = $preferences['titre']; + } - $catalogue=new Class_Catalogue(); - $preferences["aleatoire"] = 0; // les dernières seulement - $notices=$catalogue->getNoticesByPreferences($preferences,"url"); $entries = array(); - foreach($notices as $notice) { $entries []= array( 'title' => $notice["titre"].', '.$notice["auteur"], @@ -370,10 +374,10 @@ class RssController extends Zend_Controller_Action 'lastUpdate' => strtotime($notice['date_creation'])); } $rss_array = array( - 'title' => $preferences['titre'], + 'title' => $titre, 'link' => 'http://' . $_SERVER['SERVER_NAME'].BASE_URL, 'charset' => 'utf-8', - 'description' => $preferences['titre'], + 'description' => $titre, 'lastUpdate' => time(), 'entries' => $entries); diff --git a/tests/application/modules/opac/controllers/RssControllerTest.php b/tests/application/modules/opac/controllers/RssControllerTest.php index 75222e92e3a1d1df75173f7dd67732f1ecf62b96..a22f1a4c89054828f8b0990a9fbe01a5537727e6 100644 --- a/tests/application/modules/opac/controllers/RssControllerTest.php +++ b/tests/application/modules/opac/controllers/RssControllerTest.php @@ -26,6 +26,9 @@ class MockZendHttpClient extends Zend_Http_Client { } } + + + class RssControllerViewRawRssTest extends AbstractControllerTestCase { public function setUp() { parent::setUp(); @@ -97,6 +100,23 @@ class RssControllerViewRawRssTest extends AbstractControllerTestCase { + +class RssControllerKiosqueInexistingProfilTest extends AbstractControllerTestCase { + public function setUp() { + parent::setUp(); + $this->dispatch('/rss/kiosque/id_profil/-1/id_module/12', true); + } + + + /** @test */ + public function rssShouldBeEmpty() { + $this->assertNotXPath('//item'); + } +} + + + + class RssFixtures { public static function lemondeRSS() { return