diff --git a/application/modules/opac/controllers/AbonneController.php b/application/modules/opac/controllers/AbonneController.php index 260666eb307f15aeab2446cb5082e8a709b21429..c2e294cf0e9e450eea0f7302b3ac6465b07d847c 100644 --- a/application/modules/opac/controllers/AbonneController.php +++ b/application/modules/opac/controllers/AbonneController.php @@ -466,7 +466,8 @@ class AbonneController extends Zend_Controller_Action { $this->_redirect('/abonne/multimedia-hold-day'); } - $this->view->locations = Class_Multimedia_Location::getLoader()->findAllBy(array('order' => 'libelle')); + $this->view->locations = array_filter(Class_Multimedia_Location::findAllBy(['order' => 'libelle']), + function($location) {return $location->numberOfOuvertures() > 0;}); $this->view->timelineActions = $this->_getTimelineActions('location'); } diff --git a/tests/application/modules/opac/controllers/AbonneControllerMultimediaTest.php b/tests/application/modules/opac/controllers/AbonneControllerMultimediaTest.php index 8f71d438781070ba4a5eb55bb39e3b505d016529..9623480fd77faeb91cb826928445ef5bc48704a5 100644 --- a/tests/application/modules/opac/controllers/AbonneControllerMultimediaTest.php +++ b/tests/application/modules/opac/controllers/AbonneControllerMultimediaTest.php @@ -476,11 +476,22 @@ class AbonneControllerMultimediaHoldLocationTest extends AbonneControllerMultime parent::setUp(); Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Multimedia_Location') ->whenCalled('findAllBy') - ->answers(array( - Class_Multimedia_Location::getLoader()->newInstanceWithId(1) - ->setLibelle('Salle 1'), - Class_Multimedia_Location::getLoader()->newInstanceWithId(2) - ->setLibelle('Salle 2'))); + ->answers([ + Class_Multimedia_Location::newInstanceWithId(1) + ->setLibelle('Salle 1') + ->setBib(Class_Bib::newInstanceWithId(1)) + ->setOuvertures([Class_Ouverture::chaqueLundi('8:00', '12:00', '13:00', '18:00')->cache()]), + + Class_Multimedia_Location::newInstanceWithId(2) + ->setLibelle('Salle 2') + ->setBib(Class_Bib::newInstanceWithId(2)) + ->setOuvertures([Class_Ouverture::chaqueMercredi('8:00', '12:00', '13:00', '18:00')->cache()]), + + Class_Multimedia_Location::newInstanceWithId(3) + ->setLibelle('Salle 3') + ->setBib(Class_Bib::newInstanceWithId(3)) + ->setOuvertures([]) + ]); $this->dispatch('/abonne/multimedia-hold-location', true); } @@ -507,6 +518,12 @@ class AbonneControllerMultimediaHoldLocationTest extends AbonneControllerMultime public function locationSalle2ShouldBePresent() { $this->assertXPathContentContains('//a[contains(@href, "/multimedia-hold-location/location/2")]', 'Salle 2'); } + + + /** @test */ + public function locationSalle3WithoutAnyOuvertureShouldNotBePresent() { + $this->assertNotXPath('//a[contains(@href, "/multimedia-hold-location/location/3")]'); + } }