diff --git a/library/Class/WebService/SIGB/BiblixNet/PatronInfoReader.php b/library/Class/WebService/SIGB/BiblixNet/PatronInfoReader.php index 8e2ed36c54ef85735a092bb8cb4290200b1d11db..37d06e5359fa27bec41fc7e839d14189138d33b6 100644 --- a/library/Class/WebService/SIGB/BiblixNet/PatronInfoReader.php +++ b/library/Class/WebService/SIGB/BiblixNet/PatronInfoReader.php @@ -53,6 +53,14 @@ class Class_WebService_SIGB_BiblixNet_PatronInfoReader extends Class_WebService_ } + /** + * @param string $data + */ + public function endBarcode($data) { + $this->_getCurrentOperation()->getExemplaire()->setCodeBarre($data); + } + + /** * @param string $data */ diff --git a/library/Class/WebService/SIGB/BiblixNet/Service.php b/library/Class/WebService/SIGB/BiblixNet/Service.php index 3adc80a3fcdcb008dae8581b36feb0421b4a4ca1..737368f226cafeb096f362846c67511d0f9b55e2 100644 --- a/library/Class/WebService/SIGB/BiblixNet/Service.php +++ b/library/Class/WebService/SIGB/BiblixNet/Service.php @@ -43,8 +43,8 @@ class Class_Webservice_SIGB_BiblixNet_Service extends Class_WebService_SIGB_Abst */ public function getEmprunteur($user) { return $this->ilsdiGetPatronInfo(array('patronId' => $user->getIdSigb(), - 'show_loans' => 'true', - 'show_holds' => 'true'), + 'showLoans' => '1', + 'showHolds' => '1'), Class_WebService_SIGB_BiblixNet_PatronInfoReader::newInstance()); } diff --git a/library/Class/WebService/SIGB/Exemplaire.php b/library/Class/WebService/SIGB/Exemplaire.php index 4a61a8ac476cd4002706aefd179524cf080d6725..cfa76f89a20f3ccad6147e6cba3af11974d54b31 100644 --- a/library/Class/WebService/SIGB/Exemplaire.php +++ b/library/Class/WebService/SIGB/Exemplaire.php @@ -88,11 +88,19 @@ class Class_WebService_SIGB_Exemplaire { * @return Class_Exemplaire */ public function getExemplaireOPAC() { - if (!isset($this->_exemplaire_opac) and $this->getNoNotice()) - $this->_exemplaire_opac = Class_Exemplaire::getLoader() - ->findFirstBy(array('id_origine' => $this->getNoNotice())); - - return $this->_exemplaire_opac; + if (isset($this->_exemplaire_opac)) + return $this->_exemplaire_opac; + + if ($no_notice = $this->getNoNotice()) + $params = array('id_origine' => $no_notice); + + if ($this->code_barre) + $params = array('code_barres' => $this->code_barre); + + if (!isset($params)) + return null; + + return $this->_exemplaire_opac = Class_Exemplaire::getLoader()->findFirstBy($params); } diff --git a/tests/library/Class/WebService/SIGB/BiblixNetFixtures.php b/tests/library/Class/WebService/SIGB/BiblixNetFixtures.php index 02537e13ea7995c78d8dc5a338a8c9257ea1dfdc..7e0c4b3bdbaee8fbb644dfd5cc2d1007f6f3e1b9 100644 --- a/tests/library/Class/WebService/SIGB/BiblixNetFixtures.php +++ b/tests/library/Class/WebService/SIGB/BiblixNetFixtures.php @@ -107,14 +107,14 @@ class BiblixNetFixtures { <firstName>Justin</firstName> <loans> <loan> - <bibId>117661</bibId> <itemId>196895</itemId> + <barcode>1069005966314</barcode> <title>Béart en public</title> <dueDate>2011-05-04</dueDate> </loan> <loan> - <bibId>83413</bibId> <itemId>107177</itemId> + <barcode>1089005966245</barcode> <title>Les Finances publiques et la réforme budgétaire</title> <dueDate>2029-05-04</dueDate> </loan> @@ -122,12 +122,10 @@ class BiblixNetFixtures { <holds> <hold> <bibId>7307</bibId> - <itemId>7105</itemId> <state>En attente</state> </hold> <hold> - <bibId>12501</bibId> - <itemId>14586</itemId> + <bibId>14586</bibId> <state>Disponible</state> </hold> </holds> diff --git a/tests/library/Class/WebService/SIGB/BiblixNetTest.php b/tests/library/Class/WebService/SIGB/BiblixNetTest.php index cfa66c1436e3a29a3561c23a9f179e025bc771ff..ae14cbe36a3a10f1b75cba20aa1005ef0093cf6e 100644 --- a/tests/library/Class/WebService/SIGB/BiblixNetTest.php +++ b/tests/library/Class/WebService/SIGB/BiblixNetTest.php @@ -157,13 +157,23 @@ class BiblixNetGetPatronInfoJustinTicou extends BiblixNetTestCase { $this->_mock_web_client ->whenCalled('open_url') - ->with('http://mediathequewormhout.biblixnet.com/exporte_afi/?service=GetPatronInfo&patronId=34&show_loans=true&show_holds=true') + ->with('http://mediathequewormhout.biblixnet.com/exporte_afi/?service=GetPatronInfo&patronId=34&showLoans=1&showHolds=1') ->answers(BiblixNetFixtures::xmlGetPatronJustinTicou()) ->beStrict(); $this->_emprunteur = $this->_service->getEmprunteur(Class_Users::getLoader() ->newInstance() ->setIdSigb(34)); + + Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Exemplaire') + ->whenCalled('findFirstBy') + ->with(array('code_barres' => '1069005966314')) + ->answers( + Class_Exemplaire::getLoader() + ->newInstanceWithId(34) + ->setNotice( + Class_Notice::getLoader() + ->newInstanceWithId('117661'))); } @@ -197,8 +207,14 @@ class BiblixNetGetPatronInfoJustinTicou extends BiblixNetTestCase { /** @test */ - public function firstLoanNoNoticeShouldBe117661() { - $this->assertEquals(117661, $this->_emprunteur->getEmprunts()[0]->getNoNotice()); + public function firstLoanCodeBarreShouldBe1069005966314() { + $this->assertEquals(1069005966314, $this->_emprunteur->getEmprunts()[0]->getCodeBarre()); + } + + + /** @test */ + public function firstLoanNoticeShouldBe117661() { + $this->assertEquals(117661, $this->_emprunteur->getEmprunts()[0]->getNoticeOPAC()->getId()); } @@ -220,12 +236,6 @@ class BiblixNetGetPatronInfoJustinTicou extends BiblixNetTestCase { } - /** @test */ - public function firstHoldIdShouldBe7105() { - $this->assertEquals(7105, $this->_emprunteur->getReservations()[0]->getId()); - } - - /** @test */ public function firstHoldEtatShouldBeEnAttente() { $this->assertEquals('En attente', $this->_emprunteur->getReservations()[0]->getEtat());