From 4e0bd577703e51ef473398c9f3e5b290a5e0fc40 Mon Sep 17 00:00:00 2001
From: llaffont <llaffont@git-test.afi-sa.fr>
Date: Thu, 30 Aug 2012 08:25:42 +0000
Subject: [PATCH] =?UTF-8?q?Multimedia:=20affichage=20nom=20biblioth=C3=A8q?=
 =?UTF-8?q?ue=20au=20lieu=20du=20site=20sur=20toutes=20les=20phases=20de?=
 =?UTF-8?q?=20r=C3=A9servation?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../opac/controllers/AbonneController.php     |  9 ++-
 library/Class/Multimedia/Device.php           |  6 ++
 library/Class/Multimedia/DeviceGroup.php      |  6 ++
 library/Class/Multimedia/DeviceHold.php       | 18 +++++
 .../ZendAfi/View/Helper/Abonne/Multimedia.php |  4 +-
 .../AbonneControllerMultimediaTest.php        | 66 +++++++++++--------
 6 files changed, 75 insertions(+), 34 deletions(-)

diff --git a/application/modules/opac/controllers/AbonneController.php b/application/modules/opac/controllers/AbonneController.php
index 581d784b7fa..2d78dab7c37 100644
--- a/application/modules/opac/controllers/AbonneController.php
+++ b/application/modules/opac/controllers/AbonneController.php
@@ -627,7 +627,7 @@ class AbonneController extends Zend_Controller_Action {
 		}
 
 		$this->view->timelineActions = $this->_getTimelineActions('confirm');
-		$this->view->location = $bean->getLocation()->getLibelle();
+		$this->view->location = $bean->getLocation()->getLibelleBib();
 		$this->view->day = strftime('%d %B %Y', strtotime($bean->day));
 		$this->view->time = str_replace(':', 'h', $bean->time);
 		$this->view->duration = $bean->duration . 'mn';
@@ -638,7 +638,7 @@ class AbonneController extends Zend_Controller_Action {
 
 
 	public function multimediaHoldViewAction() {
-		if (null == ($hold = Class_Multimedia_DeviceHold::getLoader()->find((int)$this->_getParam('id')))) {
+		if (null == ($hold = Class_Multimedia_DeviceHold::find((int)$this->_getParam('id')))) {
 			$this->_redirect('/abonne/fiche');
 			return;
 		}
@@ -654,12 +654,11 @@ class AbonneController extends Zend_Controller_Action {
 			return;
 		}
 			
-		$this->view->location = $hold->getDevice()->getGroup()->getLocation()->getLibelle();
+		$this->view->location = $hold->getLibelleBib();
 		$this->view->day = strftime('%d %B %Y', $hold->getStart());
 		$this->view->time = strftime('%Hh%M', $hold->getStart());
 		$this->view->duration = (($hold->getEnd() - $hold->getStart()) / 60)  . 'mn';
-		$this->view->device = $hold->getDevice()->getLibelle()
-				                  . ' - ' . $hold->getDevice()->getOs();
+		$this->view->device = $hold->getLibelleDevice() . ' - ' . $hold->getOs();
 	}
 		
 
diff --git a/library/Class/Multimedia/Device.php b/library/Class/Multimedia/Device.php
index 4231aa5465d..969fbd881ec 100644
--- a/library/Class/Multimedia/Device.php
+++ b/library/Class/Multimedia/Device.php
@@ -270,6 +270,12 @@ class Class_Multimedia_Device extends Storm_Model_Abstract {
 	}
 
 
+	/** @return string */
+	public function getLibelleBib() {
+		return $this->getGroup()->getLibelleBib();
+	}
+
+
 	/** @return int */
 	public function getAuthDelay() {
 		return $this->getGroup()->getAuthDelay();
diff --git a/library/Class/Multimedia/DeviceGroup.php b/library/Class/Multimedia/DeviceGroup.php
index 6f59b3ecba9..ec916245df0 100644
--- a/library/Class/Multimedia/DeviceGroup.php
+++ b/library/Class/Multimedia/DeviceGroup.php
@@ -117,4 +117,10 @@ class Class_Multimedia_DeviceGroup extends Storm_Model_Abstract {
 	public function getAutoholdMinTime() {
 		return $this->getLocation()->getAutoholdMinTime();
 	}
+
+
+	/** @return string */
+	public function getLibelleBib() {
+		return $this->getLocation()->getLibelleBib();
+	}
 }
\ No newline at end of file
diff --git a/library/Class/Multimedia/DeviceHold.php b/library/Class/Multimedia/DeviceHold.php
index f2f2cd3eb92..f4c4790068b 100644
--- a/library/Class/Multimedia/DeviceHold.php
+++ b/library/Class/Multimedia/DeviceHold.php
@@ -222,5 +222,23 @@ class Class_Multimedia_DeviceHold extends Storm_Model_Abstract {
 		return date('H:i', $this->getEnd());
 	}
 
+
+	/** @return string */
+	public function getLibelleBib() {
+		return $this->getDevice()->getLibelleBib();
+	}
+
+
+	/** @return string */
+	public function getOS() {
+		return $this->getDevice()->getOs();
+	}
+
+
+	/** @return string */
+	public function getLibelleDevice() {
+		return $this->getDevice()->getLibelle();
+	}
+
 }
 ?>
\ No newline at end of file
diff --git a/library/ZendAfi/View/Helper/Abonne/Multimedia.php b/library/ZendAfi/View/Helper/Abonne/Multimedia.php
index 5efb7af955a..b2eff0e418a 100644
--- a/library/ZendAfi/View/Helper/Abonne/Multimedia.php
+++ b/library/ZendAfi/View/Helper/Abonne/Multimedia.php
@@ -39,9 +39,9 @@ class ZendAfi_View_Helper_Abonne_Multimedia extends ZendAfi_View_Helper_Abonne_A
 																				 'id' => $hold->getId()],
 																				null,	true),
 											 $device->getLibelle() . ' - ' . $device->getOs(),
-											 strftime('Le %d %B %Y à %Hh%M', $hold->getStart()),
+											 strftime('le %d %B %Y à %Hh%M', $hold->getStart()),
 											 sprintf('pour %smn', (($hold->getEnd() - $hold->getStart()) / 60)),
-											 $location->getLibelle());
+											 $location->getLibelleBib());
 		}
 
 		$html .= '</ul>';
diff --git a/tests/application/modules/opac/controllers/AbonneControllerMultimediaTest.php b/tests/application/modules/opac/controllers/AbonneControllerMultimediaTest.php
index 3ee9d402b57..5e08df2a9e4 100644
--- a/tests/application/modules/opac/controllers/AbonneControllerMultimediaTest.php
+++ b/tests/application/modules/opac/controllers/AbonneControllerMultimediaTest.php
@@ -420,7 +420,7 @@ abstract class AbonneControllerMultimediaHoldTestCase extends AbstractController
 		$this->_bean->location = 123;
 
 		Class_Bib::newInstanceWithId(3)
-			->setLibelle('Antibes');
+			->setLibelle('Médiathèque d\'Antibes');
 
 		
 		Class_Multimedia_Location::newInstanceWithId(123)
@@ -977,7 +977,7 @@ class AbonneControllerMultimediaHoldConfirmTest extends AbonneControllerMultimed
 		
 	/** @test */
 	public function locationShouldBeAntibes() {
-		$this->assertXPathContentContains('//li', 'Lieu : Antibes');
+		$this->assertXPathContentContains('//li', 'Lieu : Médiathèque d\'Antibes');
 	}
 
 
@@ -1047,24 +1047,26 @@ class AbonneControllerMultimediaHoldConfirmValidatedTest extends AbonneControlle
 class AbonneControllerMultimediaHoldViewTest extends AbonneControllerMultimediaHoldTestCase {
 	public function setUp() {
 		parent::setUp();
-		Class_Multimedia_DeviceHold::getLoader()->newInstanceWithId(455)
-				->setUser(Class_Users::getLoader()->getIdentity())
-				->setDevice(Class_Multimedia_Device::getLoader()->newInstanceWithId(34)
-					->setLibelle('Poste 34')
-					->setOs('Archlinux')
-					->setGroup(Class_Multimedia_DeviceGroup::getLoader()->newInstanceWithId(1)
-						->setLibelle('Groupe 1')
-						->setLocation(Class_Multimedia_Location::getLoader()->newInstanceWithId(1)
-							->setLibelle('Antibes'))))
-				->setStart(strtotime('2012-12-28 14:30:00'))
-				->setEnd(strtotime('2012-12-28 16:00:00'));
+		Class_Multimedia_DeviceHold::newInstanceWithId(455)
+			->setUser(Class_Users::getIdentity())
+			->setDevice(Class_Multimedia_Device::newInstanceWithId(34)
+									->setLibelle('Poste 34')
+									->setOs('Archlinux')
+									->setGroup(Class_Multimedia_DeviceGroup::newInstanceWithId(1)
+														 ->setLibelle('Groupe 1')
+														 ->setLocation(Class_Multimedia_Location::newInstanceWithId(1)
+																					 ->setLibelle('Antibes')
+																					 ->setBib(Class_Bib::newInstanceWithId(5)
+																										->setLibelle('Médiathèque d\'Antibes')))))
+			->setStart(strtotime('2012-12-28 14:30:00'))
+			->setEnd(strtotime('2012-12-28 16:00:00'));
 		$this->dispatch('/abonne/multimedia-hold-view/id/455', true);
 	}
 
 
 	/** @test */
 	public function locationShouldBeAntibes() {
-		$this->assertXPathContentContains('//li', 'Lieu : Antibes');
+		$this->assertXPathContentContains('//li', 'Lieu : Médiathèque d\'Antibes');
 	}
 
 
@@ -1151,20 +1153,23 @@ class AbonneControllerMultimediaHoldViewOfAnotherUserTest extends AbonneControll
 class AbonneControllerMultimediaHoldFicheAbonneTest extends AbstractControllerTestCase {
 	public function setUp() {
 		parent::setUp();
-		Class_AdminVar::getLoader()->newInstanceWithId('MULTIMEDIA_KEY')
-				->setValeur('aaaaaaaaaaaaaaabbaabba');
+		Class_AdminVar::newInstanceWithId('MULTIMEDIA_KEY')->setValeur('aaaaaaaaaaaaaaabbaabba');
+
 		Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Multimedia_DeviceHold')
-				->whenCalled('getFutureHoldsOfUser')
-				->with(Class_Users::getLoader()->getIdentity())
-				->answers(array(Class_Multimedia_DeviceHold::getLoader()->newInstanceWithId(12)
-					->setStart(strtotime('2012-28-12 14:00:00'))
-					->setEnd(strtotime('2012-28-12 15:00:00'))
-					->setDevice(Class_Multimedia_Device::getLoader()->newInstanceWithId(34)
-						->setLibelle('Poste 1')
-						->setOs('Archlinux')
-						->setGroup(Class_Multimedia_DeviceGroup::getLoader()->newInstanceWithId(3)
-							->setLocation(Class_Multimedia_Location::getLoader()->newInstanceWithId(2)
-								->setLibelle('Antibes'))))));
+			->whenCalled('getFutureHoldsOfUser')
+			->with(Class_Users::getIdentity())
+			->answers([Class_Multimedia_DeviceHold::newInstanceWithId(12)
+								 ->setStart(strtotime('2012-12-28 14:00:00'))
+								 ->setEnd(strtotime('2012-12-28 15:00:00'))
+								 ->setDevice(Class_Multimedia_Device::newInstanceWithId(34)
+														 ->setLibelle('Poste 1')
+														 ->setOs('Archlinux')
+														 ->setGroup(Class_Multimedia_DeviceGroup::newInstanceWithId(3)
+																				->setLocation(Class_Multimedia_Location::newInstanceWithId(2)
+																											->setLibelle('Antibes')
+																											->setBib(Class_Bib::newInstanceWithId(5)
+																															 ->setLibelle('Médiathèque d\'Antibes')))))
+								 ]);
 		$this->dispatch('/abonne/fiche', true);
 	}
 
@@ -1179,6 +1184,13 @@ class AbonneControllerMultimediaHoldFicheAbonneTest extends AbstractControllerTe
 	public function viewHoldLinkShouldBePresent() {
 		$this->assertXPath('//a[contains(@href, "multimedia-hold-view/id/12")]');
 	}
+
+
+	/** @test */
+	public function viewHoldLinkShouldBeDisplayLibelleBibOsAndTime() {
+		$this->assertXPathContentContains('//a[contains(@href, "multimedia-hold-view/id/12")]',
+																			'Poste 1 - Archlinux, le 28 décembre 2012 à 14h00 pour 60mn, Médiathèque d\'Antibes');
+	}
 }
 
 
-- 
GitLab