From edee9975d59cb4c00c623fd06d79c788e1aaf788 Mon Sep 17 00:00:00 2001
From: Alex Arnaud <alex.arnaud@biblibre.com>
Date: Thu, 9 Jul 2015 17:18:00 +0200
Subject: [PATCH] dev #24821 - Carthame, Nanook and Orphee ILS are able to set
 a hold "waiting to be pulled"

---
 .../SIGB/Carthame/AccountResponseReader.php        |  3 +++
 .../WebService/SIGB/Nanook/PatronInfoReader.php    |  4 +++-
 .../SIGB/Orphee/GetLstRsvResponseReader.php        |  3 +++
 .../library/Class/WebService/SIGB/CarthameTest.php |  6 ++++++
 tests/library/Class/WebService/SIGB/NanookTest.php |  6 ++++++
 .../Class/WebService/SIGB/OrpheeFixtures.php       | 14 ++++++++++++++
 .../Class/WebService/SIGB/OrpheeServiceTest.php    |  6 ++++++
 7 files changed, 41 insertions(+), 1 deletion(-)

diff --git a/library/Class/WebService/SIGB/Carthame/AccountResponseReader.php b/library/Class/WebService/SIGB/Carthame/AccountResponseReader.php
index ebe2536e56a..8810517441a 100644
--- a/library/Class/WebService/SIGB/Carthame/AccountResponseReader.php
+++ b/library/Class/WebService/SIGB/Carthame/AccountResponseReader.php
@@ -117,6 +117,9 @@ class Class_WebService_SIGB_Carthame_AccountResponseReader {
 
 		$data = (string)$data;
 		$this->_current_reservation->setEtat(isset($mapping[$data]) ? $mapping[$data] : '');
+
+		if (isset($data) && $data == 'D')
+			$this->_current_reservation->setWaitingToBePulled();
 	}
 
 
diff --git a/library/Class/WebService/SIGB/Nanook/PatronInfoReader.php b/library/Class/WebService/SIGB/Nanook/PatronInfoReader.php
index b4b0ce53933..d8db2582757 100644
--- a/library/Class/WebService/SIGB/Nanook/PatronInfoReader.php
+++ b/library/Class/WebService/SIGB/Nanook/PatronInfoReader.php
@@ -147,8 +147,10 @@ class Class_WebService_SIGB_Nanook_PatronInfoReader extends Class_WebService_SIG
 	 * @param string $data 
 	 */
 	public function endAvailable($data) {
-		if (1 == (int)$data)
+		if (1 == (int)$data) {
 			$this->_currentHold->setEtat('Disponible');
+			$this->_currentHold->setWaitingToBePulled();
+		}
 	}
 
 
diff --git a/library/Class/WebService/SIGB/Orphee/GetLstRsvResponseReader.php b/library/Class/WebService/SIGB/Orphee/GetLstRsvResponseReader.php
index 65244980c8d..726630a6cb6 100644
--- a/library/Class/WebService/SIGB/Orphee/GetLstRsvResponseReader.php
+++ b/library/Class/WebService/SIGB/Orphee/GetLstRsvResponseReader.php
@@ -86,6 +86,9 @@ class Class_WebService_SIGB_Orphee_GetLstRsvResponseReader extends Class_WebServ
 
 	public function endSit($data) {
 		$this->_current_reservation->setEtat(trim($data));
+
+		if (trim($data) != 'en attente')
+			$this->_current_reservation->setWaitingToBePulled();
 	}
 
 
diff --git a/tests/library/Class/WebService/SIGB/CarthameTest.php b/tests/library/Class/WebService/SIGB/CarthameTest.php
index c41fc3982fb..6afb205919d 100644
--- a/tests/library/Class/WebService/SIGB/CarthameTest.php
+++ b/tests/library/Class/WebService/SIGB/CarthameTest.php
@@ -410,6 +410,12 @@ class CarthameEmprunteurPatrickBTest extends CarthameOperationTestCase {
 	}
 
 
+	/** @test */
+	public function nbOfHoldsWaitingToBePulledShouldBeOne() {
+		$this->assertCount(1, $this->emprunteur->getHoldsWaitingToBePulled());
+	}
+
+
 	/** @test */
 	public function nbEmpruntShouldBeTwo() {
 		$this->assertEquals(2, $this->emprunteur->getNbEmprunts());
diff --git a/tests/library/Class/WebService/SIGB/NanookTest.php b/tests/library/Class/WebService/SIGB/NanookTest.php
index e0ecfa97e6f..c53707def45 100644
--- a/tests/library/Class/WebService/SIGB/NanookTest.php
+++ b/tests/library/Class/WebService/SIGB/NanookTest.php
@@ -614,6 +614,12 @@ class NanookGetEmprunteurChristelDelpeyrouxTest extends NanookTestCase {
 	}
 
 
+	/** @test */
+	public function nbWaitingToBePulledShouldBeOne() {
+		$this->assertCount(1, $this->_emprunteur->getHoldsWaitingToBePulled());
+	}
+
+
 	/** @test */
 	public function firstReservationIdShouldBe7105() {
 		$this->assertEquals('7105', $this->_emprunteur->getReservationAt(0)->getId());
diff --git a/tests/library/Class/WebService/SIGB/OrpheeFixtures.php b/tests/library/Class/WebService/SIGB/OrpheeFixtures.php
index 9552d3ee308..4015b314c73 100644
--- a/tests/library/Class/WebService/SIGB/OrpheeFixtures.php
+++ b/tests/library/Class/WebService/SIGB/OrpheeFixtures.php
@@ -387,6 +387,20 @@ renouvellement -->
       <rang>1</rang>
       <anx_nxt>R</anx_nxt>
     </document>
+    <document>
+      <cb></cb>
+      <no_ntc><![CDATA[975467778]]></no_ntc>
+      <no_dmt><![CDATA[790]]></no_dmt>
+      <sup><![CDATA[Livre]]></sup>
+      <tit><![CDATA[Le singe bleu]]></tit>
+      <auteur><![CDATA[Steinbeck, John (1902-1968)]]></auteur>
+      <editeur><![CDATA[Gallimard]]></editeur>
+      <sit><![CDATA[????????]]></sit>
+      <date_crea><![CDATA[09/06/2008]]></date_crea>
+      <date_fin></date_fin>
+      <rang>1</rang>
+      <anx_nxt>R</anx_nxt>
+    </document>
   </documents>
 </datas> ';
 	}
diff --git a/tests/library/Class/WebService/SIGB/OrpheeServiceTest.php b/tests/library/Class/WebService/SIGB/OrpheeServiceTest.php
index be6dcacffd6..9ed3999e537 100644
--- a/tests/library/Class/WebService/SIGB/OrpheeServiceTest.php
+++ b/tests/library/Class/WebService/SIGB/OrpheeServiceTest.php
@@ -731,6 +731,12 @@ class OrpheeServiceGetInfoUserCarteHenryDupontTest extends OrpheeServiceTestCase
 	}
 
 
+	/** @test */
+	public function nbOfHoldsWaitingToBePulledShouldBeOne() {
+		$this->assertCount(1, $this->emprunteur->getHoldsWaitingToBePulled());
+	}
+
+
 	/** @test */
 	public function getIdShouldAnswer100753() {
 		$this->assertEquals('100753', $this->emprunteur->getId());
-- 
GitLab