From 86827bbdd2cc07824d1e8500e99d8f2540ef3923 Mon Sep 17 00:00:00 2001
From: llaffont <laurent.laffont@gmail.com>
Date: Mon, 3 Mar 2014 18:11:57 +0100
Subject: [PATCH] SIGB Orphee: get site label instead of library label in hold
 list

---
 library/Class/Exemplaire.php                          | 11 +++++++++++
 .../SIGB/Orphee/GetLstPretResponseReader.php          |  2 +-
 .../RechercheControllerAlbumAudioRecordTest.php       |  5 +++++
 .../Class/WebService/SIGB/OrpheeServiceTest.php       |  8 +++++---
 4 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/library/Class/Exemplaire.php b/library/Class/Exemplaire.php
index c0c37662fec..08393715f00 100644
--- a/library/Class/Exemplaire.php
+++ b/library/Class/Exemplaire.php
@@ -30,6 +30,10 @@ class Class_Exemplaire extends Storm_Model_Abstract {
 		'bib' => ['model' => 'Class_Bib',
 							'referenced_in' => 'id_bib'],
 
+		'site' => ['model' => 'Class_CodifAnnexe',
+							 'referenced_in' => 'annexe'],
+
+
 		'album' => ['model' => 'Class_Album',
 								'referenced_in' => 'id_origine'],
 
@@ -54,6 +58,13 @@ class Class_Exemplaire extends Storm_Model_Abstract {
 	}
 
 
+	public function getLibelleSite() {
+		if (!$site = $this->getSite())
+			return '';
+		return $site->getLibelle();
+	}
+
+
 	public function getDateRetour() {
 		if ($this->hasPret())
 			return $this->getPret()->getDateRetour();
diff --git a/library/Class/WebService/SIGB/Orphee/GetLstPretResponseReader.php b/library/Class/WebService/SIGB/Orphee/GetLstPretResponseReader.php
index 08331069061..f75ff473551 100644
--- a/library/Class/WebService/SIGB/Orphee/GetLstPretResponseReader.php
+++ b/library/Class/WebService/SIGB/Orphee/GetLstPretResponseReader.php
@@ -87,7 +87,7 @@ class Class_WebService_SIGB_Orphee_GetLstPretResponseReader extends Class_WebSer
 
 			$this->_current_emprunt->getExemplaire()->setNoNotice($notice->getId());
 			$this->_current_emprunt->setTitre($notice->getTitrePrincipal());
-			$this->_current_emprunt->getExemplaire()->setBibliotheque($exemplaire_opac->getBib()->getLibelle());
+			$this->_current_emprunt->getExemplaire()->setBibliotheque($exemplaire_opac->getLibelleSite());
 			$this->_current_emprunt->setAuteur($notice->getAuteurPrincipal());
 		}
 	}
diff --git a/tests/application/modules/opac/controllers/RechercheControllerAlbumAudioRecordTest.php b/tests/application/modules/opac/controllers/RechercheControllerAlbumAudioRecordTest.php
index cee33ca145c..7794d8dfead 100644
--- a/tests/application/modules/opac/controllers/RechercheControllerAlbumAudioRecordTest.php
+++ b/tests/application/modules/opac/controllers/RechercheControllerAlbumAudioRecordTest.php
@@ -133,6 +133,11 @@ class RechercheControllerAlbumAudioRecordViewNoticeTest extends RechercheControl
 		$this->assertEquals('unknown',
 												$this->_notice->getMorceaux()['morceaux'][1][3]['titre']);
 	}
+
+	/** @test */
+	public function titresFulltextShouldContainsMOONCHILD() {
+		$this->assertContains('MOONCHILD', $this->_notice->getRawAttributes()['titres']);
+	}
 }
 
 
diff --git a/tests/library/Class/WebService/SIGB/OrpheeServiceTest.php b/tests/library/Class/WebService/SIGB/OrpheeServiceTest.php
index 72b973709e3..7d4a6909433 100644
--- a/tests/library/Class/WebService/SIGB/OrpheeServiceTest.php
+++ b/tests/library/Class/WebService/SIGB/OrpheeServiceTest.php
@@ -716,14 +716,16 @@ class OrpheeServiceGetInfoUserCarteHenryDupontTest extends OrpheeServiceTestCase
 		$ex_potter = Class_Exemplaire::getLoader()
 			->newInstanceWithId(23)
 			->setCodeBarres('123456')
-			->setBib(Class_Bib::getLoader()
-							 ->newInstanceWithId(3)
-							 ->setLibelle('Annecy Bonlieu'))
+			->setAnnexe(3)
 			->setNotice(Class_Notice::getLoader()
 									->newInstanceWithId(5)
 									->setTitrePrincipal('Harry Potter')
 									->setAuteurPrincipal('Rowling'));
 
+		Class_CodifAnnexe::getLoader()
+			->newInstanceWithId(3)
+			->setLibelle('Annecy Bonlieu');
+
 
 		$ex_chemin = Class_Exemplaire::getLoader()
 			->newInstanceWithId(32)
-- 
GitLab