diff --git a/library/Class/WebService/SIGB/Koha/PatronInfoReader.php b/library/Class/WebService/SIGB/Koha/PatronInfoReader.php index ce39f777078e8c56464002a71ccb29a6bfb3f657..b3dd81dce1b7a3f491ad3249f468548d596e44b3 100644 --- a/library/Class/WebService/SIGB/Koha/PatronInfoReader.php +++ b/library/Class/WebService/SIGB/Koha/PatronInfoReader.php @@ -54,6 +54,16 @@ class Class_WebService_SIGB_Koha_PatronInfoReader extends Class_WebService_SIGB_ if ($this->_xml_parser->inParents('hold')) $this->_current_operation->setId($id)->setNoNotice($id); } + + + public function endHoldingbranch($data) { + $data = trim($data); + if (!$this->_currentLoan || !$data + || !($site = Class_CodifAnnexe::findFirstBy(['code' => $data]))) + return; + + $this->_current_operation->getExemplaire()->setBibliotheque($site->getLibelle()); + } } ?> \ No newline at end of file diff --git a/tests/library/Class/WebService/SIGB/KohaTest.php b/tests/library/Class/WebService/SIGB/KohaTest.php index aa95635b812572cede2873d668f3971b558d460c..5416169ba3349cb6f6e77a769f6ab06e1c05ee75 100644 --- a/tests/library/Class/WebService/SIGB/KohaTest.php +++ b/tests/library/Class/WebService/SIGB/KohaTest.php @@ -52,6 +52,7 @@ class KohaGetServiceTest extends PHPUnit_Framework_TestCase { abstract class KohaTestCase extends PHPUnit_Framework_TestCase { + use Storm_Test_THelpers; protected $mock_web_client; protected $service; @@ -417,82 +418,99 @@ class KohaGetEmprunteurJeanAndreWithIdSIGBTest extends KohaTestCase { ->will($this->returnValue(KohaFixtures::xmlGetPatronInfoJeanAndre())); $this->jean = $this->service->getEmprunteur( - Class_Users::newInstanceWithId(43, ['login' => 'JEAN', - 'password' => 'zork', - 'id_sigb' => '01234'])); + $this->fixture('Class_Users', ['id' => 43, + 'login' => 'JEAN', + 'password' => 'zork', + 'id_sigb' => '01234'])); + + $this->fixture('Class_CodifAnnexe', ['id' => 33, + 'libelle' => 'Testing branch', + 'code' => 'BIB']); + + Class_Exemplaire::beVolatile(); + Class_Notice::beVolatile(); } /** @test */ - function idShouldBe419() { + public function idShouldBe419() { $this->assertEquals(419, $this->jean->getId()); } /** @test */ - function prenomShouldBeJeanAndre() { + public function prenomShouldBeJeanAndre() { $this->assertEquals('Jean-André', $this->jean->getPrenom()); } /** @test */ - function nbEmpruntsShouldBeTwo() { + public function nbEmpruntsShouldBeTwo() { $this->assertEquals(2, $this->jean->getNbEmprunts()); } /** @test */ - function nbReservationsShouldReturnZero() { + public function nbReservationsShouldReturnZero() { $this->assertEquals(0, $this->jean->getNbReservations()); } /** @test */ - function firstEmpruntTitreShouldBeLaGuitareEn10Lecons() { - $this->assertEquals("La guitare en 10 leçons", $this->jean->getEmpruntAt(0)->getTitre()); + public function firstEmpruntTitreShouldBeLaGuitareEn10Lecons() { + $this->assertEquals('La guitare en 10 leçons', + $this->jean->getEmpruntAt(0)->getTitre()); } /** @test */ - function firstEmpruntDateRetourShouldBe18_04_2009() { + public function firstEmpruntDateRetourShouldBe18_04_2009() { $this->assertEquals('18/04/2009', $this->jean->getEmpruntAt(0)->getDateRetour()); } + /** @test */ - function firstEmpruntCodeBorreShouldBe2700017UUU() { + public function firstEmpruntCodeBorreShouldBe2700017UUU() { $this->assertEquals('2700017UUU', $this->jean->getEmpruntAt(0)->getCodeBarre()); } /** @test */ - function secondEmpruntTitreShouldBeLIleAuTresor() { - $this->assertEquals("L'Île au trésor", $this->jean->getEmpruntAt(1)->getTitre()); + public function firstEmpruntLibraryShouldBeTestingBranch() { + $this->assertEquals('Testing branch', + $this->jean->getEmpruntAt(0)->getBibliotheque()); } /** @test */ - function secondEmpruntIdShouldBe4454() { - $this->assertEquals("4454", $this->jean->getEmpruntAt(1)->getId()); + public function secondEmpruntTitreShouldBeLIleAuTresor() { + $this->assertEquals('L\'Île au trésor', $this->jean->getEmpruntAt(1)->getTitre()); } /** @test */ - function secondEmpruntExemplaireIdShouldBe4454() { - $this->assertEquals("4454", $this->jean->getEmpruntAt(1)->getExemplaire()->getId()); + public function secondEmpruntIdShouldBe4454() { + $this->assertEquals('4454', $this->jean->getEmpruntAt(1)->getId()); } /** @test */ - function secondEmpruntAuteurShouldBeRobertLouisStevenson() { - $this->assertEquals("Robert Louis Stevenson", $this->jean->getEmpruntAt(1)->getAuteur()); + public function secondEmpruntExemplaireIdShouldBe4454() { + $this->assertEquals('4454', $this->jean->getEmpruntAt(1)->getExemplaire()->getId()); } - /** @test */ - function secondEmpruntDateDueShouldBe06052009() { - $this->assertEquals('06/05/2009', $this->jean->getEmpruntAt(1)->getDateRetour()); + /** @test */ + public function secondEmpruntAuteurShouldBeRobertLouisStevenson() { + $this->assertEquals('Robert Louis Stevenson', + $this->jean->getEmpruntAt(1)->getAuteur()); } + + /** @test */ + public function secondEmpruntDateDueShouldBe06052009() { + $this->assertEquals('06/05/2009', $this->jean->getEmpruntAt(1)->getDateRetour()); + } }