From e061a685d46b05e6b706a1cb8780dc40089f3002 Mon Sep 17 00:00:00 2001
From: adiouf <adiouf@afi-sa.fr>
Date: Wed, 1 Apr 2015 18:01:33 +0200
Subject: [PATCH] Removal management post multimedia reservations from the
 BOKEH and adding a service to determine a closing day

---
 .../controllers/MultimediaController.php      |  28 +---
 .../opac/controllers/AbonneController.php     |   7 +-
 .../Class/Multimedia/AuthenticateRequest.php  |  30 +++-
 library/Class/Multimedia/Device.php           |  42 ++---
 library/Class/Multimedia/DeviceGroup.php      |   9 +-
 library/Class/Multimedia/Location.php         |  13 +-
 .../AbonneControllerMultimediaTest.php        | 158 +++++++-----------
 tests/library/Class/Multimedia/DeviceTest.php |   1 -
 .../library/Class/Multimedia/LocationTest.php |  25 +--
 9 files changed, 123 insertions(+), 190 deletions(-)

diff --git a/application/modules/admin/controllers/MultimediaController.php b/application/modules/admin/controllers/MultimediaController.php
index 3767d71b141..9f1760669a0 100644
--- a/application/modules/admin/controllers/MultimediaController.php
+++ b/application/modules/admin/controllers/MultimediaController.php
@@ -39,10 +39,7 @@ class Admin_MultimediaController extends ZendAfi_Controller_Action {
 																					'elements' => $this->getConfigFields()],
 
 														 'config_auto' => ['legend' => 'Réservation automatique',
-																							 'elements' => $this->getConfigAutoFields()],
-
-														 'config_auto_closing_days' => ['legend' => 'Réservation les jours de fermetures',
-																							 'elements' => $this->getConfigClosingDaysFields()]
+																							 'elements' => $this->getConfigAutoFields()]
 														 ]
 						];
 	}
@@ -131,29 +128,6 @@ disponible',
 	}
 
 
-	public function getConfigClosingDaysFields() {
-		$hours_select = Class_Multimedia_Location::getPossibleHours(30);
-
-
-		$fields['autohold_for_closing_days'] = ['element' => 'checkbox',
-													 'options' => ['label' => 'Autoriser les réservations automatique pour les jours de fermeture
-disponible',
-																				 'title' => 'Permet de définir des jours d\'utilisation des postes sans possibilités de réservation de bokeh',
-																				 'required' => true,
-																				 'allowEmpty' => false]];
-
-
-		$field_labels = ['open_hour' => $this->view->_('Heure d\'ouverture'),
-										 'close_hour' => $this->view->_('Heure de fermeture')];
-
-		foreach ($field_labels as $field => $label)
-			$fields[$field] = ['element' => 'select', 'options' => ['label' => $label,
-																															'multiOptions' => $hours_select]];
-
-		return $fields;
-						}
-
-
 	public function browseAction() {
 		if (!$location = Class_Multimedia_Location::find((int)$this->_getParam('id'))) {
 			$this->_redirect('/admin/multimedia');
diff --git a/application/modules/opac/controllers/AbonneController.php b/application/modules/opac/controllers/AbonneController.php
index 1860dfdd57f..9c979767044 100644
--- a/application/modules/opac/controllers/AbonneController.php
+++ b/application/modules/opac/controllers/AbonneController.php
@@ -573,7 +573,6 @@ class AbonneController extends ZendAfi_Controller_Action {
 
 		$response = new StdClass();
 		$response->auth = 0;
-		$response->until = '';
 
 		$request = Class_Multimedia_AuthenticateRequest::newWithRequest($this->_request);
 		if ($user = $request->getUser()) {
@@ -591,9 +590,13 @@ class AbonneController extends ZendAfi_Controller_Action {
 		}
 
 		$response->auth = 1;
-		$response->until = date('c', $request->getCurrentHoldEnd());
+		$response->holding = $request->canHoldingForToDay();
+		$response->holded = $request->isSuccessHolding();
+		$response->until = '';
+		if($response->holded) $response->until = date('c', $request->getCurrentHoldEnd());
 
 		$this->_response->setBody(json_encode($response));
+
 	}
 
 
diff --git a/library/Class/Multimedia/AuthenticateRequest.php b/library/Class/Multimedia/AuthenticateRequest.php
index 13f6591e936..288dfe45a2a 100644
--- a/library/Class/Multimedia/AuthenticateRequest.php
+++ b/library/Class/Multimedia/AuthenticateRequest.php
@@ -32,6 +32,11 @@ class Class_Multimedia_AuthenticateRequest {
 	/** @var Class_Multimedia_Device */
 	protected $_device;
 
+	/** @var boolean */
+	protected $_holdableDay = false;
+
+	/** @var boolean */
+	protected $_successHolding = false;
 
 	/**
 	 * @param Zend_Controller_Request_Abstract
@@ -79,19 +84,36 @@ class Class_Multimedia_AuthenticateRequest {
 		if (!$this->_device)
 			return $this->_error('DeviceNotFound');
 
-		if (!$this->getCurrentHold())
-			return $this->_error('DeviceNotHeldByUser');
+		$mode = $request->getParam('mode');
+		if(isset($mode) && $mode === 'holdable-day'){
+			$this->_holdableDay = $this->_device->isHoldableDayToDay();
+		}
+
+		if (isset($mode) && $mode === 'hold'){
+			$temps = $request->getParam('temps');
+			if(!$this->getCurrentHold($temps))
+				return $this->_error('DeviceNotHeldByUser');
+			$this->_successHolding = true;
+		}
 
 		return $this->beValid();
 	}
 
 
+	public function canHoldingForToDay(){
+		return $this->_holdableDay;
+	}
+
+	public function isSuccessHolding(){
+		return $this->_successHolding;
+	}
+
 	/**
 	 * @return Class_Multimedia_DeviceHold
 	 */
-	public function getCurrentHold() {
+	public function getCurrentHold($temps=null) {
 		if (!isset($this->_current_hold) && isset($this->_device) && isset($this->_user))
-			$this->_current_hold = $this->_device->getCurrentHoldForUser($this->_user);
+			$this->_current_hold = $this->_device->getCurrentHoldForUser($this->_user, $temps);
 		return $this->_current_hold;
 	}
 
diff --git a/library/Class/Multimedia/Device.php b/library/Class/Multimedia/Device.php
index 10d3c86e198..c1e60878b61 100644
--- a/library/Class/Multimedia/Device.php
+++ b/library/Class/Multimedia/Device.php
@@ -109,12 +109,12 @@ class Class_Multimedia_Device extends Storm_Model_Abstract {
 	 * @param $user Class_Users
 	 * @return Class_Multimedia_DeviceHold
 	 */
-	public function getCurrentHoldForUser($user) {
+	public function getCurrentHoldForUser($user, $temps=null) {
 		if (null !== ($hold = $this->getCurrentHold())
 			and $user->getId() == $hold->getIdUser())
 			return $hold;
 
-		return $this->autoHoldByUser($user, $hold);
+		return $this->autoHoldByUser($user, $hold, $temps);
 	}
 
 
@@ -123,22 +123,20 @@ class Class_Multimedia_Device extends Storm_Model_Abstract {
 	 * @param $current_hold Class_Multimedia_DeviceHold
 	 * @return Class_Multimedia_DeviceHold
 	 */
-	public function autoHoldByUser($user, $current_hold) {
+	public function autoHoldByUser($user, $current_hold, $temps=null) {
 		if (!$this->canCreateHoldGivenCurrentHoldAndUser($current_hold, $user))
 			return null;
 
 		// si je n'ai pas de début de créneau, on sort
-		/*if (null == ($start = $this->getPreviousStartTime()))
-			return null;*/
-
-		if (null == ($start = $this->getStartTimeForAutoHold()))
+		if (null == ($start = $this->getPreviousStartTime()))
 			return null;
 
-		$end = $this->findHoldEndForTodayFrom($start, 1);
+		$end = $this->findHoldEndForTodayFrom($start, $temps);
 
 		if ($end <= $start)
 			return null;
 
+
 		$hold = Class_Multimedia_DeviceHold::getLoader()
 				->newInstance()
 				->setDevice($this)
@@ -146,10 +144,15 @@ class Class_Multimedia_Device extends Storm_Model_Abstract {
 				->setStart($start)
 				->setEnd($end);
 		$hold->save();
+
 		return $hold;
 	}
 
 
+	public function isHoldableDayToDay(){
+		return $this->getGroup()->isHoldableDayToDay();
+	}
+
 	/**
 	 * @param Class_Multimedia_DeviceHold $current_hold
 	 * @return boolean
@@ -199,12 +202,16 @@ class Class_Multimedia_Device extends Storm_Model_Abstract {
 	 * @param timestamp $starrt
 	 * @return timestamp
 	 */
-	public function findHoldEndForTodayFrom($start, $autohold=null) {
-		// fin de créneau par défaut selon config
-		$end = $start + (60 * $this->getAutoholdSlotsMax() * $this->getSlotSize());
+	public function findHoldEndForTodayFrom($start, $temps=null) {
+
+		$nbSlotMax = (!isset($temps)) ? $this->getAutoholdSlotsMax()
+			: ceil($temps / $this->getSlotSize());
+
+    // fin de créneau par défaut selon config
+		$end = $start + (60 * $nbSlotMax * $this->getSlotSize());
 
 		// si on dépasse la fin de journée on se limite à la fin de journée
-		if ($end > ($next_closing = $this->getMaxTimeForToday($autohold)))
+		if ($end > ($next_closing = $this->getMaxTimeForToday()))
 			$end = $next_closing;
 
 		// si on dépasse la prochaine résa on se limite au début de la prochaine résa
@@ -265,13 +272,6 @@ class Class_Multimedia_Device extends Storm_Model_Abstract {
 	}
 
 
-	/** @return int */
-	public function getStartTimeForAutoHold() {
-		$time_source = new Class_TimeSource();
-		return $time_source->time();
-	}
-
-
 	/** @return int */
 	public function getNextHoldStart() {
 		if ($hold = $this->getNextHold())
@@ -289,8 +289,8 @@ class Class_Multimedia_Device extends Storm_Model_Abstract {
 
 
 	/** @return int */
-	public function getMaxTimeForToday($autohold=null) {
-		return $this->getGroup()->getMaxTimeForToday($autohold);
+	public function getMaxTimeForToday() {
+		return $this->getGroup()->getMaxTimeForToday();
 	}
 
 
diff --git a/library/Class/Multimedia/DeviceGroup.php b/library/Class/Multimedia/DeviceGroup.php
index dfe9913fffb..e73612337df 100644
--- a/library/Class/Multimedia/DeviceGroup.php
+++ b/library/Class/Multimedia/DeviceGroup.php
@@ -91,8 +91,8 @@ class Class_Multimedia_DeviceGroup extends Storm_Model_Abstract {
 
 
 	/** @return int */
-	public function getMaxTimeForToday($autohold=null) {
-		return $this->getLocation()->getMaxTimeForToday($autohold);
+	public function getMaxTimeForToday() {
+		return $this->getLocation()->getMaxTimeForToday();
 	}
 
 
@@ -120,4 +120,9 @@ class Class_Multimedia_DeviceGroup extends Storm_Model_Abstract {
 	public function getLibelleBib() {
 		return $this->getLocation()->getLibelleBib();
 	}
+
+	/** @return bool */
+	public function isHoldableDayToDay(){
+		return $this->getLocation()->isHoldableDayToDay();
+	}
 }
\ No newline at end of file
diff --git a/library/Class/Multimedia/Location.php b/library/Class/Multimedia/Location.php
index 4be16156864..94a8a8e4d10 100644
--- a/library/Class/Multimedia/Location.php
+++ b/library/Class/Multimedia/Location.php
@@ -205,9 +205,7 @@ class Class_Multimedia_Location extends Storm_Model_Abstract {
 		return null;
 	}
 
-
-
-	public function getOuvertureForDate($date, $autohold=null) {
+	public function getOuvertureForDate($date) {
 		if (is_string($date))
 			$date = strtotime($date);
 
@@ -223,8 +221,6 @@ class Class_Multimedia_Location extends Storm_Model_Abstract {
 				return $ouverture;
 		}
 
-		return ($this->getAutoholdForClosingDays() && $autohold === 1) ?
-			$this->_autoOpening() : null;
 	}
 
 
@@ -262,8 +258,8 @@ class Class_Multimedia_Location extends Storm_Model_Abstract {
 
 
 	/** @return int */
-	public function getMaxTimeForToday($autohold = null) {
-		if (!$ouverture = $this->getOuvertureForDate(self::getTimeSource()->date(), $autohold))
+	public function getMaxTimeForToday() {
+		if (!$ouverture = $this->getOuvertureForDate(self::getTimeSource()->date()))
 			return 0;
 		return $ouverture->getNextCloseFrom($this->getCurrentTime());
 	}
@@ -352,6 +348,9 @@ class Class_Multimedia_Location extends Storm_Model_Abstract {
 																		 }));
 	}
 
+	public function isHoldableDayToDay(){
+		return (!$ouverture = $this->getOuvertureForDate(self::getTimeSource()->date())) ? false : true;
+	}
 
 	public function beforeSave() {
 		if (is_array($days = $this->getDays()))
diff --git a/tests/application/modules/opac/controllers/AbonneControllerMultimediaTest.php b/tests/application/modules/opac/controllers/AbonneControllerMultimediaTest.php
index bcb33bef6ca..407d779ca84 100644
--- a/tests/application/modules/opac/controllers/AbonneControllerMultimediaTest.php
+++ b/tests/application/modules/opac/controllers/AbonneControllerMultimediaTest.php
@@ -24,14 +24,30 @@ require_once 'application/modules/opac/controllers/AbonneController.php';
 
 trait TAbonneControllerMultimediaFixtureHoldSuccessOnSept12 {
 	protected function _launch() {
-		$this->onLoaderOfModel('Class_Multimedia_Location')
+/*		$this->onLoaderOfModel('Class_Multimedia_Location')
 			->whenCalled('findByIdOrigine')
 			->answers(Class_Multimedia_Location::newInstanceWithId(1));
 
 
 		$this->onLoaderOfModel('Class_Multimedia_Device')
 			->whenCalled('findByIdOrigineAndLocation')
-			->answers(Class_Multimedia_Device::newInstanceWithId(1));
+			->answers(Class_Multimedia_Device::newInstanceWithId(1));*/
+		$this->fixture('Class_Multimedia_Device',
+									 ['id' => 1,
+										'id_origine' => '1-1',
+										'group' => $this->fixture('Class_Multimedia_DeviceGroup',
+																								 ['id' => 1,
+																									'location' => $this->fixture('Class_Multimedia_Location',
+																																							 ['id' => 1, 'id_origine' => 1,
+																																								'ouvertures' => $this->fixture('Class_Ouverture',
+																																																											['id' => 1,
+																																																											 'Jour' => '2012-09-12',
+																																																											 'horaires' => ['08:00', '12:00', '12:00', '18:00']])
+																																							 ])
+																								 ])
+													]);
+
+
 
 		$this->onLoaderOfModel('Class_Multimedia_DeviceHold')
 			->whenCalled('getHoldOnDeviceAtTime')
@@ -246,13 +262,12 @@ class AbonneControllerMultimediaAuthenticateInviteAfiMultimediaTest extends Abon
 }
 
 
-
-
 abstract class AbonneControllerMultimediaAuthenticateValidTestCase extends AbonneControllerMultimediaAuthenticateTestCase {
 	protected $_user;
 	protected $_group;
 
 	public function setUp() {
+		Class_Multimedia_Location::setTimeSource(new TimeSourceForTest('2012-09-12 09:00:00'));
 		parent::setUp();
 
 		$this->_initUser();
@@ -261,21 +276,47 @@ abstract class AbonneControllerMultimediaAuthenticateValidTestCase extends Abonn
 		$this->_launch();
 	}
 
+	protected function _initUser() {}
+}
 
+abstract class AbonneControllerMultimediaCheckedHoldableDayTestCase extends AbonneControllerMultimediaAuthenticateValidTestCase {
 	protected function _launch() {
-		$this->_json = $this->getJson(sprintf('/abonne/authenticate/login/%s/password/%s/poste/1/site/1',
+		$this->_json = $this->getJson(sprintf('/abonne/authenticate/login/%s/password/%s/poste/1/site/1/mode/holdable-day',
 																					$this->_user->getLogin(),
 																					$this->_user->getPassword()));
 	}
 
+}
+
+
+class AbonneControllerMultimediaHoldableDay extends AbonneControllerMultimediaCheckedHoldableDayTestCase {
+		use
+		TAbonneControllerMultimediaFixtureHoldSuccessOnSept12,
+		TAbonneControllerMultimediaFixtureWithUserLaurentInDevsAgiles;
+
+		/** @test */
+		public function shouldHaveAuth() {
+			$this->assertEquals(1, $this->_json->auth);
+		}
+
+		/** @test */
+		public function shouldHaveHoldedDay() {
+			$this->assertEquals(1, $this->_json->holding);
+		}
 
-	protected function _initUser() {}
 }
 
 
+abstract class AbonneControllerMultimediaHoldedTestCase extends AbonneControllerMultimediaAuthenticateValidTestCase {
+	protected function _launch() {
+		$this->_json = $this->getJson(sprintf('/abonne/authenticate/login/%s/password/%s/poste/1/site/1/mode/hold',
+																					$this->_user->getLogin(),
+																					$this->_user->getPassword()));
+	}
+}
 
 
-class AbonneControllerMultimediaAuthenticateLaurentTest extends AbonneControllerMultimediaAuthenticateValidTestCase {
+class AbonneControllerMultimediaAuthenticateLaurentTest extends AbonneControllerMultimediaHoldedTestCase {
 	use
 		TAbonneControllerMultimediaFixtureHoldSuccessOnSept12,
 		TAbonneControllerMultimediaFixtureWithUserLaurentInDevsAgiles;
@@ -330,107 +371,24 @@ class AbonneControllerMultimediaAuthenticateLaurentTest extends AbonneController
 
 
 	/** @test */
-	public function shouldHaveHold() {
+	public function shouldHaveAuth() {
 		$this->assertEquals(1, $this->_json->auth);
 	}
 
-
-	/** @test */
-	public function holdShouldLastUntil16h40() {
-		$this->assertEquals('2012-09-12T16:40:00+02:00', $this->_json->until);
-	}
-}
-
-
-class AbonneControllerMultimediaAuthenticateLaurentAtClosingDaysDeviceHoldByUserTest extends AbonneControllerMultimediaAuthenticateValidTestCase {
-	use TAbonneControllerMultimediaFixtureWithUserLaurentInDevsAgiles;
-
-	protected function _launch() {
-
-		Class_Multimedia_Location::setTimeSource(new TimeSourceForTest('2012-09-12 09:30:00'));
-
-		$this->onLoaderOfModel('Class_Multimedia_Location')
-			->whenCalled('findByIdOrigine')
-			->answers($location = Class_Multimedia_Location::newInstanceWithId(1)
-								->setSlotSize(30)
-								->setAutoholdSlotsMax(1)
-								->setAuthDelay(1)
-								->setAutohold(1)
-								->setOuvertures([])
-								->setAutoholdForClosingDays(1)
-								->setOpenHour('09:00')
-								->setCloseHour('17:00'));
-
-		$this->onLoaderOfModel('Class_Multimedia_Device')
-			->whenCalled('findByIdOrigineAndLocation')
-			->answers(Class_Multimedia_Device::newInstanceWithId(1)
-								->setGroup(Class_Multimedia_DeviceGroup::newInstanceWithId(34)->setLocation($location)));
-
-
-		$this->onLoaderOfModel('Class_Multimedia_DeviceHold')
-			->whenCalled('getHoldOnDeviceAtTime')
-			->answers(null);
-
-		parent::_launch();
-	}
-
-
 	/** @test */
 	public function shouldHaveHold() {
-		$this->assertEquals(1, $this->_json->auth);
-	}
-
-	/** @test */
-	public function holdShouldLastUntil16h40() {
-		$this->assertEquals('2012-09-12T10:00:00+02:00', $this->_json->until);
-	}
-
-
-}
-
-
-class AbonneControllerMultimediaAuthenticateLaurentAtClosingDaysDeviceNotHeldByUserTest extends AbonneControllerMultimediaAuthenticateValidTestCase {
-	use TAbonneControllerMultimediaFixtureWithUserLaurentInDevsAgiles;
-
-	protected function _launch() {
-
-		Class_Multimedia_Location::setTimeSource(new TimeSourceForTest('2012-09-12 09:30:00'));
-
-		$this->onLoaderOfModel('Class_Multimedia_Location')
-			->whenCalled('findByIdOrigine')
-			->answers($location = Class_Multimedia_Location::newInstanceWithId(1)
-								->setAuthDelay(1)
-								->setAutohold(1)
-								->setOuvertures([])
-								->setAutoholdForClosingDays(0)
-								->setOpenHour('09:00')
-								->setCloseHour('17:00'));
-
-		$this->onLoaderOfModel('Class_Multimedia_Device')
-			->whenCalled('findByIdOrigineAndLocation')
-			->answers(Class_Multimedia_Device::newInstanceWithId(1)
-								->setGroup(Class_Multimedia_DeviceGroup::newInstanceWithId(34)->setLocation($location)));
-
-
-		$this->onLoaderOfModel('Class_Multimedia_DeviceHold')
-			->whenCalled('getHoldOnDeviceAtTime')
-			->answers(null);
-
-		parent::_launch();
+		$this->assertEquals(1, $this->_json->holded);
 	}
 
 
 	/** @test */
-	public function shouldHaveNotHeld() {
-		$this->assertEquals(0, $this->_json->auth);
+	public function holdShouldLastUntil16h40() {
+		$this->assertEquals('2012-09-12T16:40:00+02:00', $this->_json->until);
 	}
-
-
 }
 
 
-
-class AbonneControllerMultimediaAuthenticateLaurentDeviceNotHeldByUserTest extends AbonneControllerMultimediaAuthenticateValidTestCase {
+class AbonneControllerMultimediaAuthenticateLaurentDeviceNotHeldByUserTest extends AbonneControllerMultimediaHoldedTestCase {
 	use TAbonneControllerMultimediaFixtureWithUserLaurentInDevsAgiles;
 
 	protected function _launch() {
@@ -438,7 +396,6 @@ class AbonneControllerMultimediaAuthenticateLaurentDeviceNotHeldByUserTest exten
 			->whenCalled('findByIdOrigine')
 			->answers($location = Class_Multimedia_Location::newInstanceWithId(1)
 								->setAuthDelay(1)
-								->setAutoholdForClosingDays(0)
 								->setAutohold(1));
 
 		$this->onLoaderOfModel('Class_Multimedia_Device')
@@ -478,7 +435,7 @@ class AbonneControllerMultimediaAuthenticateLaurentDeviceNotHeldByUserTest exten
 
 
 
-class AbonneControllerMultimediaAuthenticateLaurentDeviceNotFoundTest extends AbonneControllerMultimediaAuthenticateValidTestCase {
+class AbonneControllerMultimediaAuthenticateLaurentDeviceNotFoundTest extends AbonneControllerMultimediaHoldedTestCase {
 	use TAbonneControllerMultimediaFixtureWithUserLaurentInDevsAgiles;
 	protected function _launch() {
 		$this->onLoaderOfModel('Class_Multimedia_Location')
@@ -507,7 +464,7 @@ class AbonneControllerMultimediaAuthenticateLaurentDeviceNotFoundTest extends Ab
 
 
 
-class AbonneControllerMultimediaAuthenticateArnaudTest extends AbonneControllerMultimediaAuthenticateValidTestCase {
+class AbonneControllerMultimediaAuthenticateArnaudTest extends AbonneControllerMultimediaHoldedTestCase {
 	use TAbonneControllerMultimediaFixtureHoldSuccessOnSept12;
 
 	protected function _initUser() {
@@ -531,7 +488,7 @@ class AbonneControllerMultimediaAuthenticateArnaudTest extends AbonneControllerM
 
 
 
-class AbonneControllerMultimediaAuthenticateBaptisteTest extends AbonneControllerMultimediaAuthenticateValidTestCase {
+class AbonneControllerMultimediaAuthenticateBaptisteTest extends AbonneControllerMultimediaHoldedTestCase {
 	use TAbonneControllerMultimediaFixtureHoldSuccessOnSept12;
 
 	protected function _initUser() {
@@ -560,8 +517,6 @@ class AbonneControllerMultimediaAuthenticateBaptisteTest extends AbonneControlle
 }
 
 
-
-
 /* Début test du workflow de réservation */
 abstract class AbonneControllerMultimediaHoldTestCase extends AbstractControllerTestCase {
 	protected $_session;
@@ -597,7 +552,6 @@ abstract class AbonneControllerMultimediaHoldTestCase extends AbstractController
 			->setLibelle('Antibes')
 			->setSlotSize(30)
 			->setMaxSlots(4)
-			->setAutoholdForClosingDays(0)
 			->setHoldDelayMin(0)
 			->setHoldDelayMax(60)
 			->setOuvertures([Class_Ouverture::chaqueLundi('08:30', '12:00', '12:00', '17:45')->setId(1)->cache(),
diff --git a/tests/library/Class/Multimedia/DeviceTest.php b/tests/library/Class/Multimedia/DeviceTest.php
index 9f15bd401c7..499fc6a3b33 100644
--- a/tests/library/Class/Multimedia/DeviceTest.php
+++ b/tests/library/Class/Multimedia/DeviceTest.php
@@ -179,7 +179,6 @@ class Multimedia_DeviceCurrentHoldForUserWithoutHoldAndAnotherValidHoldTest exte
 			->setAuthDelay(10)
 			->setAutohold(1)
 			->setSlotSize(15)
-			->setAutoholdForClosingDays(1)
 			->save();
 	}
 
diff --git a/tests/library/Class/Multimedia/LocationTest.php b/tests/library/Class/Multimedia/LocationTest.php
index 4ecc4ef3357..287bb49adf9 100644
--- a/tests/library/Class/Multimedia/LocationTest.php
+++ b/tests/library/Class/Multimedia/LocationTest.php
@@ -181,8 +181,7 @@ class Multimedia_LocationWithBibTest extends Multimedia_LocationWithBibTestCase
 	/** @test */
 	public function getDatesOuvertureShouldAnswersAllMercrediJeudiForNextTwoMonthsWith9and19Sept() {
 		$this->_time_source->setTime(strtotime('2012-08-05'));
-		$this->_location->setHoldDelayMax(60)
-										->setAutoholdForClosingDays(false);
+		$this->_location->setHoldDelayMax(60);
 		$this->assertEquals(['2012-08-08', '2012-08-09',
 												 '2012-08-15', '2012-08-16',
 												 '2012-08-22', '2012-08-23',
@@ -195,28 +194,6 @@ class Multimedia_LocationWithBibTest extends Multimedia_LocationWithBibTestCase
 												 '2012-10-03', '2012-10-04'],
 												$this->_location->getHoldableDays());
 	}
-
-	/** @test */
-	public function getDatesOuvertureMardiClosingDayShouldAnswersOpenHour0800() {
-		$this->_time_source->setTime(strtotime('2012-12-04'));
-		$this->_location->setAutoholdForClosingDays(true)
-										->setOpenHour('08:00')
-										->setCloseHour('17:00');
-		$this->_autohold = 1;
-		$this->assertEquals('08:00', $this->_location->getOuvertureForDate($this->_time_source->time(), $this->_autohold)->getDebutMatin());
-
-	}
-
-	/** @test */
-	public function getDatesOuvertureMardiClosingDayShouldAnswersCloseHour1700() {
-		$this->_time_source->setTime(strtotime('2012-12-04'));
-		$this->_location->setAutoholdForClosingDays(true)
-										->setOpenHour('08:00')
-										->setCloseHour('17:00');
-		$this->_autohold = 1;
-		$this->assertEquals('17:00', $this->_location->getOuvertureForDate($this->_time_source->time(),$this->_autohold)->getFinApresMidi());
-
-	}
 }
 
 
-- 
GitLab