From 46a804d5b8c0d067504373ab31ee149b08b13506 Mon Sep 17 00:00:00 2001
From: llaffont <llaffont@git-test.afi-sa.fr>
Date: Fri, 17 Aug 2012 08:46:59 +0000
Subject: [PATCH] =?UTF-8?q?Si=20aucune=20ouverture=20n'est=20d=C3=A9clar?=
 =?UTF-8?q?=C3=A9e=20pour=20un=20site=20multim=C3=A9dia,=20il=20n'appara?=
 =?UTF-8?q?=C3=AEt=20pas=20dans=20la=20liste=20pour=20faire=20une=20r?=
 =?UTF-8?q?=C3=A9servation?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../opac/controllers/AbonneController.php     |  3 ++-
 .../AbonneControllerMultimediaTest.php        | 27 +++++++++++++++----
 2 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/application/modules/opac/controllers/AbonneController.php b/application/modules/opac/controllers/AbonneController.php
index 260666eb307..c2e294cf0e9 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 8f71d438781..9623480fd77 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")]');
+	}
 }
 
 
-- 
GitLab