From f1a6c7eb07bfbf5e5cc4bd29ff635eee2d59a1e9 Mon Sep 17 00:00:00 2001 From: llaffont <llaffont@afi-sa.fr> Date: Tue, 8 Apr 2014 17:47:21 +0200 Subject: [PATCH] hotline#12864 Add non-regression test and fix when library for an item is not found --- library/Class/Exemplaire.php | 4 +++ library/Class/WebService/SIGB/Exemplaire.php | 2 +- .../controllers/AbonneControllerPretsTest.php | 27 +++++++++++++++++-- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/library/Class/Exemplaire.php b/library/Class/Exemplaire.php index 0386aa74c94..fb96f1585df 100644 --- a/library/Class/Exemplaire.php +++ b/library/Class/Exemplaire.php @@ -60,6 +60,10 @@ class Class_Exemplaire extends Storm_Model_Abstract { return $site->getLibelle(); } + public function getBibLibelle() { + return $this->hasBib() ? $this->getBib()->getLibelle() : ''; + + } public function getDateRetour() { if ($this->hasPret()) diff --git a/library/Class/WebService/SIGB/Exemplaire.php b/library/Class/WebService/SIGB/Exemplaire.php index cd786e893f6..7f096237784 100644 --- a/library/Class/WebService/SIGB/Exemplaire.php +++ b/library/Class/WebService/SIGB/Exemplaire.php @@ -177,7 +177,7 @@ class Class_WebService_SIGB_Exemplaire { public function getBibliotheque(){ if (!$this->bibliotheque and ($exemplaire = $this->getExemplaireOPAC())) - $this->bibliotheque = $exemplaire->getBib()->getLibelle(); + $this->bibliotheque = $exemplaire->getBibLibelle(); return $this->bibliotheque; } diff --git a/tests/application/modules/opac/controllers/AbonneControllerPretsTest.php b/tests/application/modules/opac/controllers/AbonneControllerPretsTest.php index a5b48fcc503..bba0097e8ff 100644 --- a/tests/application/modules/opac/controllers/AbonneControllerPretsTest.php +++ b/tests/application/modules/opac/controllers/AbonneControllerPretsTest.php @@ -207,14 +207,28 @@ class AbonneControllerPretsListReservationTest extends AbstractAbonneControllerP $exemplaire_potter = Class_Exemplaire::newInstanceWithId(918, ['id_origine' => 564, 'notice' => Class_Notice::newInstanceWithId(823, ['titre_principal' => 'Potter'])]); + + $dobby = new Class_WebService_SIGB_Reservation('13', new Class_WebService_SIGB_Exemplaire(124)); + $dobby->getExemplaire()->setTitre('Dobby'); + // This item has no library: non-regression test. + $dobby->parseExtraAttributes(array('Etat' => 'Réservation émise', + 'Rang' => '2', + 'N° de notice' => 565)); + + $exemplaire_dobby = Class_Exemplaire::newInstanceWithId(918, ['id_origine' => 565, + 'notice' => Class_Notice::newInstanceWithId(824, + ['titre_principal' => 'Dobby'])]); Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Exemplaire') ->whenCalled('findFirstBy') ->with(['id_origine' => 564]) - ->answers($exemplaire_potter); + ->answers($exemplaire_potter) + ->whenCalled('findFirstBy') + ->with(['id_origine' => 565]) + ->answers($exemplaire_dobby); $emprunteur = new Class_WebService_SIGB_Emprunteur('1234', 'Florence'); - $emprunteur->reservationsAddAll(array($potter)); + $emprunteur->reservationsAddAll(array($potter, $dobby)); $fiche_sigb = array('type_comm' => 2, //OPSYS 'fiche' => $emprunteur, @@ -296,6 +310,15 @@ class AbonneControllerPretsListReservationTest extends AbstractAbonneControllerP $this->assertXPathContentContains('//tbody/tr[1]//td', 'Tombouctou', $this->_response->getBody()); } + + + /** @test */ + public function secondReservationTitleShouldBeDobby() { + $this->assertXPathContentContains('//tbody/tr[2]//td//a', 'Dobby', + $this->_response->getBody()); + } + + } -- GitLab