From 26bd31f9ff24b045b22926c4db16a12286270d82 Mon Sep 17 00:00:00 2001 From: gloas <gloas@afi-sa.fr> Date: Thu, 19 Jan 2017 15:14:11 +0100 Subject: [PATCH] hotline #50082 fix test failures --- .../opac/controllers/AbonneController.php | 2 +- library/ZendAfi/View/Helper/Abonne/Loans.php | 2 +- .../View/Helper/Abonne/LoansExtension.php | 20 +++- .../controllers/AbonneControllerPretsTest.php | 98 ++----------------- tests/scenarios/Patron/PatronTest.php | 42 -------- 5 files changed, 28 insertions(+), 136 deletions(-) delete mode 100644 tests/scenarios/Patron/PatronTest.php diff --git a/application/modules/opac/controllers/AbonneController.php b/application/modules/opac/controllers/AbonneController.php index cddc9f53fef..7b556bac9e7 100644 --- a/application/modules/opac/controllers/AbonneController.php +++ b/application/modules/opac/controllers/AbonneController.php @@ -399,7 +399,7 @@ class AbonneController extends ZendAfi_Controller_Action { ? $this->_('Prolongation des prêts') : $this->_('Prolongation du prêt'); - $this->_renderExtendPopup($title, $this->view->abonne_LoansExtension($cards, $results, $ids)); + $this->_renderExtendPopup($title, $this->view->abonne_LoansExtension($this->_user, $cards, $results, $ids)); } diff --git a/library/ZendAfi/View/Helper/Abonne/Loans.php b/library/ZendAfi/View/Helper/Abonne/Loans.php index 3309a4a9f9d..b1b7beb57c6 100644 --- a/library/ZendAfi/View/Helper/Abonne/Loans.php +++ b/library/ZendAfi/View/Helper/Abonne/Loans.php @@ -89,7 +89,7 @@ class ZendAfi_View_Helper_Abonne_Loans extends ZendAfi_View_Helper_BaseHelper { 'id' => $record->getId(), 'retour_abonne' => 'prets'], null, true), - $record_title); + $record->getTitrePrincipal()); return $this->_tag('tr', $this->_tag('td', diff --git a/library/ZendAfi/View/Helper/Abonne/LoansExtension.php b/library/ZendAfi/View/Helper/Abonne/LoansExtension.php index c02f2f0d44c..b68e3826057 100644 --- a/library/ZendAfi/View/Helper/Abonne/LoansExtension.php +++ b/library/ZendAfi/View/Helper/Abonne/LoansExtension.php @@ -23,11 +23,13 @@ class ZendAfi_View_Helper_Abonne_LoansExtension extends ZendAfi_View_Helper_BaseHelper { protected $_cards, - $_results; + $_results, + $_user; - public function abonne_LoansExtension($cards, $results, $ids) { + public function abonne_LoansExtension($user, $cards, $results, $ids) { $this->_cards = $cards; $this->_results = $results; + $this->_user = $user; return count($ids) == 1 ? $this->_renderOneLoanExtension() @@ -71,8 +73,18 @@ class ZendAfi_View_Helper_Abonne_LoansExtension extends ZendAfi_View_Helper_Base return ''; foreach ($this->_cards->getLoansWithOutPNB() as $loan) { - if ($loan->getId() == $result['id']) - return '<br>'. $this->_tag('strong', $loan->getTitre() . ':') . ' ' . $result['erreur']; + if ($loan->getId() != $result['id']) + continue; + + $record = new Class_Entity(); + if($item = Class_Exemplaire::findFirstBySIGBOperation($this->_user, $loan)) + $record = $item->getNotice(); + + $title = $record->getId() + ? $record->getTitrePrincipal() + : $loan->getTitre(); + + return '<br>'. $this->_tag('strong', $title . ':') . ' ' . $result['erreur']; } return ''; diff --git a/tests/application/modules/opac/controllers/AbonneControllerPretsTest.php b/tests/application/modules/opac/controllers/AbonneControllerPretsTest.php index 4b77db0e996..46de07c5f66 100644 --- a/tests/application/modules/opac/controllers/AbonneControllerPretsTest.php +++ b/tests/application/modules/opac/controllers/AbonneControllerPretsTest.php @@ -488,16 +488,18 @@ class AbonneControllerPretsListThreePretsPnbEarlyReturnTest extends AbonneContro class AbonneControllerPretsListReservationTest extends AbstractAbonneControllerPretsTestCase { + protected $_storm_default_to_volatile = true; + public function setUp() { parent::setUp(); - - Class_Exemplaire::beVolatile(); - $exemplaire_potter = $this->fixture('Class_Exemplaire', - ['id' => 120, - 'notice' => $this->fixture('Class_Notice', - ['id' => 820, - 'titre_principal' => 'Potter'])]); + ['id' => 12089, + 'code_barres' => 123, + 'id_int_bib' => 1, + 'id_notice' => 820]); + $this->fixture('Class_Notice', + ['id' => 820, + 'titre_principal' => 'Potter']); $potter = (new Class_WebService_SIGB_Reservation('12', (new Class_WebService_SIGB_Exemplaire(123)) @@ -903,6 +905,7 @@ class AbonneControllerPretsPeriodicalTitleTest extends AbstractAbonneControllerP $this->fixture('Class_Exemplaire', ['id' => 967, 'id_origine' => 13340, + 'id_int_bib' => 1, 'zone995' => serialize([['clef' => 'a', 'valeur' => 'Espace Culturel'], ['clef' => 'f', 'valeur' => '0720028863'], ['clef' => 'k', 'valeur' => 'J-REV 10-N°90']]), @@ -937,84 +940,3 @@ class AbonneControllerPretsPeriodicalTitleTest extends AbstractAbonneControllerP $this->assertXPathContentContains('//a', utf8_encode('Petites mains n° 90')); } } - - - -/** @see http://forge.afi-sa.fr/issues/50082 **/ -class AbonneControllerPretsActionWithLoanMatchingDigitalResource extends AbstractControllerTestCase { - protected $_storm_default_to_volatile = true; - - public function setUp() { - parent::setUp(); - Class_WebService_SIGB_Nanook::reset(); - $mock_web_client = $this->mock() - ->whenCalled('open_url') - ->with('http://localhost:8080/afi_Nanook/ilsdi/service/AuthenticatePatron/username/7942236/password/1900') - ->answers(NanookFixtures::xmlAuthenticatePatronFrancoisMorel()) - - ->whenCalled('open_url') - ->with('http://localhost:8080/afi_Nanook/ilsdi/service/GetPatronInfo/patronId/5352') - ->answers(NanookFixtures::xmlGetPatronInfoFrancoisMorel()); - - $service = Class_WebService_SIGB_Nanook::getService(['url_serveur' => 'http://localhost:8080/afi_Nanook/ilsdi/']); - $service->setWebClient($mock_web_client); - - $this->fixture('Class_Bib', - ['id' => 3, - 'libelle' => 'Cran-Gévrier']); - - $this->fixture('Class_CodifAnnexe' , ['id' => 3, - 'libelle' => 'Annexe Cran-Gevrier', - 'id_bib' => 3, - 'code' => 10]); - - $this->fixture('Class_Bib', - ['id' => 5, - 'libelle' => 'Seynod']); - - $this->fixture('Class_IntBib', - ['id' => 5, - 'comm_sigb' => Class_IntBib::COM_NANOOK, - 'comm_params' => ['url_serveur' => 'http://bib.valensol.net']]); - - $this->fixture('Class_CodifAnnexe' , ['id' => 4, - 'libelle' => 'Annexe Seynod', - 'id_bib' => 5, - 'code' => 8]); - $user = $this->fixture('Class_Users', - ['id' => 123, - 'id_sigb' => 5352, - 'login' => 7942236, - 'password' => 1900]); - - $emprunteur = $service->getEmprunteur($user); - $emprunteur->updateUser($user); - - ZendAfi_Auth::getInstance()->logUser($user); - - $this->fixture('Class_Notice', - ['id' => 123, - 'titre_principal' => 'Le Montespan']); - - $this->fixture('Class_IntBib', - ['id' => 25, - 'comm_sigb' => Class_IntBib::COM_CDSCRIPT, - 'comm_params' => ['server_url' => 'http://bib.valensol.net', - 'remote_library_id' => 1]]); - - $this->fixture('Class_Exemplaire', - ['id' => 21, - 'id_origine' => 273559, - 'id_notice' => 123, - 'id_int_bib' => 25 - ]); - - $this->dispatch('/opac/abonne/prets', true); - } - - - /** @test */ - public function titleShouldBeUnFleuveDeFumee() { - $this->assertXPathContentContains('//td', utf8_encode('Un fleuve de fumée')); - } -} \ No newline at end of file diff --git a/tests/scenarios/Patron/PatronTest.php b/tests/scenarios/Patron/PatronTest.php deleted file mode 100644 index 32c37c4ec94..00000000000 --- a/tests/scenarios/Patron/PatronTest.php +++ /dev/null @@ -1,42 +0,0 @@ -<?php -/** - * Copyright (c) 2012-2017, Agence Française Informatique (AFI). All rights reserved. - * - * BOKEH is free software; you can redistribute it and/or modify - * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by - * the Free Software Foundation. - * - * There are special exceptions to the terms and conditions of the AGPL as it - * is applied to this software (see README file). - * - * BOKEH is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU AFFERO GENERAL PUBLIC LICENSE for more details. - * - * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE - * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - -class PatronTest extends AbstractControllerTestCase { - public function setup() { - parent::setup(); - - } - - /** @test */ - public function loanNoticeShouldBeLinked() { - $this->dispatch('/opac/abonne/loans-history', true); - $this->assertXPath('//td/a[contains(@href, "/recherche/viewnotice/id/1456/retour_abonne/prets")]'); - } - - - /** @test */ - public function loanWithoutNoticeShouldNotBeLink() { - $this->dispatch('/opac/abonne/loans-history', true); - $this->assertXPath('//td[not(a)][contains(text(), "L\'hôpital")]'); - } -} -?> \ No newline at end of file -- GitLab