From 3a97b4e9c330c1d42929da0bbdedf673e4fedd69 Mon Sep 17 00:00:00 2001
From: llaffont <llaffont@git-test.afi-sa.fr>
Date: Fri, 13 Jul 2012 08:04:10 +0000
Subject: [PATCH] =?UTF-8?q?WS=20BiblixNet:=20liaison=20avec=20la=20notice?=
 =?UTF-8?q?=20dans=20la=20liste=20des=20r=C3=A9servations?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../SIGB/BiblixNet/PatronInfoReader.php           |  3 +++
 .../Class/WebService/SIGB/ExemplaireOperation.php | 10 ++++++++++
 .../Class/WebService/SIGB/BiblixNetFixtures.php   |  4 ++--
 .../Class/WebService/SIGB/BiblixNetTest.php       | 15 ++++++++++++---
 4 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/library/Class/WebService/SIGB/BiblixNet/PatronInfoReader.php b/library/Class/WebService/SIGB/BiblixNet/PatronInfoReader.php
index 37d06e5359f..3f0db7d5c57 100644
--- a/library/Class/WebService/SIGB/BiblixNet/PatronInfoReader.php
+++ b/library/Class/WebService/SIGB/BiblixNet/PatronInfoReader.php
@@ -42,6 +42,9 @@ class Class_WebService_SIGB_BiblixNet_PatronInfoReader extends Class_WebService_
 	public function endItemId($data) {
 		$this->_getCurrentOperation()->setId($data);
 		$this->_getCurrentOperation()->getExemplaire()->setId($data);
+
+		if ($this->_xml_parser->inParents('hold'))
+			$this->_getCurrentOperation()->setNoNotice(sprintf('%011d', $data));
 	}
 
 
diff --git a/library/Class/WebService/SIGB/ExemplaireOperation.php b/library/Class/WebService/SIGB/ExemplaireOperation.php
index 07aaeb16e3d..3f1e1ee98d0 100644
--- a/library/Class/WebService/SIGB/ExemplaireOperation.php
+++ b/library/Class/WebService/SIGB/ExemplaireOperation.php
@@ -173,6 +173,16 @@ abstract class Class_WebService_SIGB_ExemplaireOperation {
 	}
 
 
+	/**
+	 * @param no_notice int
+	 * @return Class_WebService_SIGB_ExemplaireOperation
+	 */
+	public function setNoNotice($no_notice) {
+		$this->_exemplaire->setNoNotice($no_notice);
+		return $this;
+	}
+
+
 	/**
 	 * @param exemplaire Class_Exemplaire
 	 * @return Class_WebService_SIGB_ExemplaireOperation
diff --git a/tests/library/Class/WebService/SIGB/BiblixNetFixtures.php b/tests/library/Class/WebService/SIGB/BiblixNetFixtures.php
index 7e0c4b3bdba..f7069f5c3aa 100644
--- a/tests/library/Class/WebService/SIGB/BiblixNetFixtures.php
+++ b/tests/library/Class/WebService/SIGB/BiblixNetFixtures.php
@@ -121,11 +121,11 @@ class BiblixNetFixtures {
   </loans>
   <holds>
     <hold>
-      <bibId>7307</bibId>
+      <itemId>7307</itemId>
 			<state>En attente</state>
     </hold>
     <hold>
-      <bibId>14586</bibId>
+      <itemId>14586</itemId>
 			<state>Disponible</state>
     </hold>
   </holds>
diff --git a/tests/library/Class/WebService/SIGB/BiblixNetTest.php b/tests/library/Class/WebService/SIGB/BiblixNetTest.php
index ae14cbe36a3..f630087cc91 100644
--- a/tests/library/Class/WebService/SIGB/BiblixNetTest.php
+++ b/tests/library/Class/WebService/SIGB/BiblixNetTest.php
@@ -173,7 +173,16 @@ class BiblixNetGetPatronInfoJustinTicou extends BiblixNetTestCase {
 				->newInstanceWithId(34)
 				->setNotice(
 					Class_Notice::getLoader()
-					->newInstanceWithId('117661')));
+					->newInstanceWithId('117661')))
+
+			->whenCalled('findFirstBy')
+			->with(array('id_origine' => '00000007307'))
+			->answers(
+				Class_Exemplaire::getLoader()
+				->newInstanceWithId(36)
+				->setNotice(
+					Class_Notice::getLoader()
+					->newInstanceWithId('7307')));
 	}
 
 
@@ -231,8 +240,8 @@ class BiblixNetGetPatronInfoJustinTicou extends BiblixNetTestCase {
 
 
 	/** @test */
-	public function firstHoldNoNoticeShouldBe7307() {
-		$this->assertEquals(7307, $this->_emprunteur->getReservations()[0]->getNoNotice());
+	public function firstHoldExemplaireOPACShouldBeTheOneWithId36() {
+		$this->assertEquals(36, $this->_emprunteur->getReservations()[0]->getExemplaireOPAC()->getId());
 	}
 
 
-- 
GitLab