diff --git a/VERSIONS_HOTLINE/201687 b/VERSIONS_HOTLINE/201687 new file mode 100644 index 0000000000000000000000000000000000000000..adc2b0f0274973f725e59d7d158b399e8ff11f35 --- /dev/null +++ b/VERSIONS_HOTLINE/201687 @@ -0,0 +1 @@ + - correctif #201687 : Fiche abonné : Récupération des prêts numériques des carte liées pour le thème historique. \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/Abonne/LoansBoard.php b/library/ZendAfi/View/Helper/Abonne/LoansBoard.php index 964ec9c66623d2c0771c5e0549b1c9865ce563dd..ea0cb6c36d54b9947325a0de61f8d9d46bd3562b 100644 --- a/library/ZendAfi/View/Helper/Abonne/LoansBoard.php +++ b/library/ZendAfi/View/Helper/Abonne/LoansBoard.php @@ -95,10 +95,10 @@ class ZendAfi_View_Helper_Abonne_LoansBoard extends ZendAfi_View_Helper_BaseHelp protected function _renderPNB() { - $user = $this->_config->getUser(); - return ($user->hasPNB()) + $cards = new Class_User_Cards($this->_config->getUser()); + return ($cards->hasPNB()) ? ($this->_tag('h2', $this->_('Prêts numériques en cours')) - . $this->view->abonne_LoansPNB($user->getDecoratedCardsFromPNBLoans())) + . $this->view->abonne_LoansPNB($cards->getPNBLoans())) : ''; } diff --git a/tests/library/ZendAfi/View/Helper/Abonne/PretsTest.php b/tests/library/ZendAfi/View/Helper/Abonne/PretsTest.php new file mode 100644 index 0000000000000000000000000000000000000000..d5fccc73feb7c1161ff57f78a62d9701eb2c4b6e --- /dev/null +++ b/tests/library/ZendAfi/View/Helper/Abonne/PretsTest.php @@ -0,0 +1,162 @@ +<?php +/** + * Copyright (c) 2012-2024, 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 View_Helper_Abonne_PretsTest extends ViewHelperTestCase +{ + public function setUp() + { + parent::setUp(); + + $helper = new ZendAfi_View_Helper_Abonne_LoansBoard(); + $helper->setView(new ZendAfi_Controller_Action_Helper_View()); + + $logged_in = $this->fixture(Class_Users::class, + ['id' => 17151, + 'nom' => 'Martin', + 'prenom' => 'Alice', + 'login' => 'amartin', + 'password' => 'secret', + 'id_site' => 1, + 'idabon' => '987987', + 'role_level' => ZendAfi_Acl_AdminControllerRoles::ABONNE_SIGB]); + + $child = $this->fixture(Class_Users::class, + ['id' => 19863, + 'nom' => 'Martin', + 'prenom' => 'Jean', + 'login' => 'jmartin', + 'password' => 'secret', + 'id_site' => 1, + 'idabon' => '987988', + 'role_level' => ZendAfi_Acl_AdminControllerRoles::ABONNE_SIGB]); + + $this->fixture(Class_LinkedCard::class, + ['id' => 100, + 'parent_id' => 17151, + 'child_id' => 19863]); + + $this->fixture(Class_Loan_Pnb::class, + ['id' => 56, + 'subscriber_id' => $child->getIdabon(), + 'ongoing' => true, + 'expected_return_date' => '2024-07-02T18:14:14+02:00', + 'options' => 'LCP', + 'loan_date' => '2024-06-30T15:10:02+02:00', + 'album' => $this->fixture(Class_Album::class, + ['id' => 4, + 'notice_id' => 5, + 'id_origine' => 'Dilicom-88817216', + 'titre' => 'Pinocchio'])->addAuthor('Collodi')]); + + $http_client = $this->mock() + ->whenCalled('open_url') + ->with('/v3/pnb-numerique/json/getEndedLoans?loanId%5B0%5D=56', + ['auth' => [ 'user' => null, + 'password' => null]]) + ->answers('{ + "requestId":"aw01v2_000000041_201502261519", + "returnStatus":"OK", + "returnMessage":"", + "loanEndedResponseLine":[] +}') + + ->beStrict(); + + + Class_WebService_BibNumerique_Dilicom_Hub::setDefaultHttpClient($http_client); + + $this->_time_source = new TimeSourceForTest('2024-06-30 16:51:09'); + + Class_WebService_BibNumerique_Dilicom_Hub::setTimeSource($this->_time_source); + Class_Loan_Pnb::setTimeSource($this->_time_source); + Class_WebService_SIGB_Emprunt::setTimeSource($this->_time_source); + + $config = new class($logged_in) + { + protected $_user; + + + public function __construct($user) + { + $this->_user = $user; + } + + + public function getUser() + { + return $this->_user; + } + + + public function getRequestParams() + { + return ['controller' => 'abonne', + 'action' => 'prets', + 'module' => 'opac']; + } + + + public function getProfile() + { + return Class_Profil::find(1); + } + }; + + ZendAfi_Auth::getInstance()->logUser($logged_in); + $this->html = $helper->abonne_LoansBoard($config); + + } + + + public function tearDown() { + Class_WebService_BibNumerique_Dilicom_Hub::setDefaultHttpClient(null); + Class_WebService_BibNumerique_Dilicom_Hub::setTimeSource(null); + Class_Loan_Pnb::setTimeSource(null); + Class_WebService_SIGB_Emprunt::setTimeSource(null); + + parent::tearDown(); + } + + + /** @test */ + public function htmlShouldContainPretsNumeriquesEnCours() + { + $this->assertXPathContentContains($this->html, '//h2', + Class_CharSet::fromISOtoUTF8('Prêts numériques en cours')); + } + + + /** @test */ + public function htmlShouldContainPNBLoanTitle() + { + $this->assertXPathContentContains($this->html, + '//a[@href="/recherche/viewnotice/id/5/retour_abonne/prets"]', + 'Pinocchio'); + } + + + /** @test */ + public function htmlShouldContainPNBLoanAuthor() + { + $this->assertXPathContentContains($this->html, '//td', 'Collodi'); + } +}