From 86379ccaef8187e293b52fa6569392136c531db6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?ANDRE=20s=C3=A9bastien?= <sandre@afi-sa.fr> Date: Fri, 24 May 2024 12:41:12 +0000 Subject: [PATCH] hotline : #202507 : borrowerlinks doesnt have tests for loansperpage * change class underscorized on templates --- VERSIONS_HOTLINE/202507 | 1 + .../views/scripts/auth/boitelogin.phtml | 2 +- library/Class/User/Cards.php | 8 +- library/Class/Users.php | 5 +- library/Class/WebService/SIGB/Emprunteur.php | 11 +- .../ZendAfi/View/Helper/FicheAbonneLinks.php | 17 ++- .../EtatFrancais/Assets/css/etatfrancais.css | 4 +- .../templates/Intonation/Library/Settings.php | 9 +- .../Library/Widget/Login/RenderAbstract.php | 4 +- .../Intonation/View/User/BorrowerLinks.php | 123 +++++++++--------- .../scenarios/Payfip/PayfipSubscriberTest.php | 10 +- .../Payfip/PayfipTemplatesAbonneTest.php | 6 +- .../Templates/TemplatesAbonnePretsTest.php | 8 +- .../Templates/TemplatesBorrowerTest.php | 75 +++++++++++ 14 files changed, 186 insertions(+), 97 deletions(-) create mode 100644 VERSIONS_HOTLINE/202507 create mode 100644 tests/scenarios/Templates/TemplatesBorrowerTest.php diff --git a/VERSIONS_HOTLINE/202507 b/VERSIONS_HOTLINE/202507 new file mode 100644 index 00000000000..42db705bee5 --- /dev/null +++ b/VERSIONS_HOTLINE/202507 @@ -0,0 +1 @@ + - correctif #202507 : Magasin de thème : Boite login, affichage des prêts en cours ne provoque plus de page blanche. \ No newline at end of file diff --git a/application/modules/telephone/views/scripts/auth/boitelogin.phtml b/application/modules/telephone/views/scripts/auth/boitelogin.phtml index fad1f6205b2..1bdea7b642d 100644 --- a/application/modules/telephone/views/scripts/auth/boitelogin.phtml +++ b/application/modules/telephone/views/scripts/auth/boitelogin.phtml @@ -13,7 +13,7 @@ if($user = Class_Users::getLoader()->getIdentity()) { if ($user->hasIdabon()) echo implode($this->ficheAbonneLinks($user->getIlsLoansCount(), $user->getNbEmpruntsRetard(), - $user->getNbReservations())); + (int) $user->getNbReservations())); } else { $form = new ZendAfi_Form_Mobile_Login(); diff --git a/library/Class/User/Cards.php b/library/Class/User/Cards.php index 0a843c1693f..42e70b169fe 100644 --- a/library/Class/User/Cards.php +++ b/library/Class/User/Cards.php @@ -109,11 +109,9 @@ class Class_User_Cards extends Storm_Model_Collection { } - public function hasPagedLoans() :bool { - return null !== $this->detect(function($card) - { - return $card->hasPagedLoans(); - }); + public function hasPagedLoans(): bool + { + return null !== $this->detect(fn($card) => $card->hasPagedLoans()); } diff --git a/library/Class/Users.php b/library/Class/Users.php index c9198284703..57e300aeac8 100644 --- a/library/Class/Users.php +++ b/library/Class/Users.php @@ -1201,8 +1201,9 @@ class Class_Users extends Storm_Model_Abstract { } - public function hasPagedLoans() { - if (!($emprunteur = $this->getEmprunteur())) + public function hasPagedLoans(): bool + { + if ( ! ($emprunteur = $this->getEmprunteur())) return false; $emprunteur->ensureService($this); diff --git a/library/Class/WebService/SIGB/Emprunteur.php b/library/Class/WebService/SIGB/Emprunteur.php index 32d43ecf57b..118e8c4965e 100644 --- a/library/Class/WebService/SIGB/Emprunteur.php +++ b/library/Class/WebService/SIGB/Emprunteur.php @@ -511,20 +511,17 @@ class Class_WebService_SIGB_Emprunteur public function hasLoansPerPage(): bool { - if(!isset($this->_service)) + if ( ! isset($this->_service)) return false; - if(!$this->_service->providesPagedLoans()) + if ( ! $this->_service->providesPagedLoans()) return false; if ((null !== $this->_service->getLoansPerPage()) - && ($this->getNbEmprunts() <= (int)$this->_service->getLoansPerPage())) + && ($this->getNbEmprunts() <= $this->_service->getLoansPerPage())) return false; - if (0 < $this->_service->getLoansPerPage()) - return true; - - return false; + return $this->_service->getLoansPerPage() > 0; } diff --git a/library/ZendAfi/View/Helper/FicheAbonneLinks.php b/library/ZendAfi/View/Helper/FicheAbonneLinks.php index 90e304e862d..3b2aacf712c 100644 --- a/library/ZendAfi/View/Helper/FicheAbonneLinks.php +++ b/library/ZendAfi/View/Helper/FicheAbonneLinks.php @@ -18,8 +18,13 @@ * along with BOKEH; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -class ZendAfi_View_Helper_FicheAbonneLinks extends ZendAfi_View_Helper_BaseHelper { - public function ficheAbonneLinks($nb_prets, $nb_retards, $nb_reservations) { + + +class ZendAfi_View_Helper_FicheAbonneLinks extends ZendAfi_View_Helper_BaseHelper +{ + + public function ficheAbonneLinks(int $nb_prets, int $nb_retards, int $nb_reservations): array + { $html = []; if ($nb_prets || $nb_retards) @@ -32,7 +37,8 @@ class ZendAfi_View_Helper_FicheAbonneLinks extends ZendAfi_View_Helper_BaseHelpe } - protected function _getLoansCount($nb_prets, $nb_retards) { + protected function _getLoansCount(int $nb_prets, int $nb_retards) + { $loans = $this->view->tagAnchor(['controller' => 'abonne', 'action' => 'prets'], $this->view->_plural($nb_prets, @@ -55,7 +61,8 @@ class ZendAfi_View_Helper_FicheAbonneLinks extends ZendAfi_View_Helper_BaseHelpe } - protected function _getHoldsCount($nb_reservations) { + protected function _getHoldsCount(int $nb_reservations) + { return $this->view->tagAnchor(['controller' => 'abonne', 'action' => 'reservations'], $this->view->_plural($nb_reservations, @@ -65,4 +72,4 @@ class ZendAfi_View_Helper_FicheAbonneLinks extends ZendAfi_View_Helper_BaseHelpe $nb_reservations), ['class'=>'account-booking']); } -} \ No newline at end of file +} diff --git a/library/templates/EtatFrancais/Assets/css/etatfrancais.css b/library/templates/EtatFrancais/Assets/css/etatfrancais.css index fe12a06ffc8..3f04768d702 100644 --- a/library/templates/EtatFrancais/Assets/css/etatfrancais.css +++ b/library/templates/EtatFrancais/Assets/css/etatfrancais.css @@ -896,11 +896,11 @@ li.result_follow_search img { filter: invert(1); } -a.card-link.account-link.btn.btn-sm.btn-primary:hover { +a.card-link.account_link.btn.btn-sm.btn-primary:hover { color: #000091; } -a.card-link.account-disconnect.btn.btn-sm.btn-secondary:hover { +a.card-link.account_disconnect.btn.btn-sm.btn-secondary:hover { color: #333; } diff --git a/library/templates/Intonation/Library/Settings.php b/library/templates/Intonation/Library/Settings.php index 9ea97942565..82d1e7c982d 100644 --- a/library/templates/Intonation/Library/Settings.php +++ b/library/templates/Intonation/Library/Settings.php @@ -137,7 +137,10 @@ class Intonation_Library_Settings extends Intonation_System_Abstract { 'a class list_format' => 'btn btn-light', 'a class nav-link' => 'text-light', 'a class jumbotron_nav_link' => 'text-dark', - 'a class account-loans' => 'btn btn-sm list-group-item-info', + 'a class account_all_loans' => 'btn btn-sm list-group-item-info', + 'a class account_current_loans' => 'btn btn-sm list-group-item-info', + 'a class account_late_loans' => 'btn btn-sm list-group-item-info', + 'a class account_others_holds' => 'btn btn-sm list-group-item-info', 'a class more_action' => 'text-primary', 'a class badge' => '', 'a class active' => '', @@ -319,8 +322,8 @@ class Intonation_Library_Settings extends Intonation_System_Abstract { 'div class library_opening_hours' => 'col-12 d-none', 'div class menu_with_carousel_layout' => 'overflow-visible', 'div class record_no_thumbnail' => 'card card-img-overlay', - 'a class account-link' => 'btn btn-sm btn-primary', - 'a class account-disconnect' => 'btn btn-sm btn-secondary', + 'a class account_link' => 'btn btn-sm btn-primary', + 'a class account_disconnect' => 'btn btn-sm btn-secondary', 'span class user_notifications' => 'btn btn-sm list-group-item-danger', 'div class babeltheque_reviews' => 'mt-3 mb-3', 'span class truncate_list_size' => 'btn btn-sm btn-info', diff --git a/library/templates/Intonation/Library/Widget/Login/RenderAbstract.php b/library/templates/Intonation/Library/Widget/Login/RenderAbstract.php index 5c136fb3662..98e5e700092 100644 --- a/library/templates/Intonation/Library/Widget/Login/RenderAbstract.php +++ b/library/templates/Intonation/Library/Widget/Login/RenderAbstract.php @@ -167,7 +167,7 @@ abstract class Intonation_Library_Widget_Login_RenderAbstract { ->setUrl($url) ->setText($this->_view->abonne_Name($this->_user)) ->setTitle($this->_('Accéder à l\'interface de gestion de %s.', $this->_user->getNomComplet())) - ->setAttrib('class', 'account-link') + ->setAttrib('class', 'account_link') ->alwaysDisplayText(); } @@ -178,7 +178,7 @@ abstract class Intonation_Library_Widget_Login_RenderAbstract { 'action'=>'logout'], null, true)) ->setText($this->_settings->getLienDeconnection()) ->setTitle($this->_('Se déconnecter de la session %s', $this->_user->getNomComplet())) - ->setAttrib('class', 'account-disconnect') + ->setAttrib('class', 'account_disconnect') ->alwaysDisplayText(); } diff --git a/library/templates/Intonation/View/User/BorrowerLinks.php b/library/templates/Intonation/View/User/BorrowerLinks.php index 9c60523e0c0..d0982eaf28c 100644 --- a/library/templates/Intonation/View/User/BorrowerLinks.php +++ b/library/templates/Intonation/View/User/BorrowerLinks.php @@ -20,32 +20,33 @@ */ -class Intonation_View_User_BorrowerLinks extends ZendAfi_View_Helper_FicheAbonneLinks { +class Intonation_View_User_BorrowerLinks extends ZendAfi_View_Helper_FicheAbonneLinks +{ - - public function User_BorrowerLinks(Class_User_Cards $cards) : array { - $debts_links=''; + public function User_BorrowerLinks(Class_User_Cards $cards): array + { + $debts_links = ''; if ($this->_showDebts()) $debts_links = $this->_renderNumberOfDebts(); if (Class_Users::getIdentity()->displaySimpleAccountLinks()) - return array_filter([ ...$this->_displaySimpleAccountLinks(), $debts_links]); + return array_filter([...$this->_displaySimpleAccountLinks(), $debts_links]); if ($cards->hasPagedLoans()) - return array_filter([ ...$this->_displayLoansPagesAllLink(), $debts_links]); + return array_filter([$this->_displayLoansPagesAllLink(), $debts_links]); $loans_count = $cards->getLoansCount(); $late_loans_count = $cards->getLateLoansCount(); $holds_count = $cards->getHoldsCount(); - $account_links =[]; + $account_links = []; if ($loans_count || $late_loans_count) - $account_links[] = $this->_getLoansCount($loans_count, $late_loans_count); + $account_links [] = $this->_getLoansCount($loans_count, $late_loans_count); if ($holds_count) - $account_links[] = $this->_getHoldsCount($holds_count); + $account_links [] = $this->_getHoldsCount($holds_count); if ($debts_links) array_push($account_links, $debts_links); @@ -54,98 +55,103 @@ class Intonation_View_User_BorrowerLinks extends ZendAfi_View_Helper_FicheAbonne } - - - protected function _getLoansCount($nb_prets, $nb_retards) { + protected function _getLoansCount(int $nb_prets, int $nb_retards) + { return (new Intonation_Library_Link) ->setText($this->view->_plural($nb_prets, - "", - "%d prêt en cours", - "%d prêts en cours", + '', + '%d prêt en cours', + '%d prêts en cours', $nb_prets). $this->view->_plural($nb_retards, - "", - ", %d en retard", - ", %d en retard", + '', + ', %d en retard', + ', %d en retard', $nb_retards)) - ->setAttrib('class', 'account-loans' . ( $nb_retards ? ' pret_en_retard' : '')) + ->setAttrib('class', 'account_all_loans' . ($nb_retards ? ' pret_en_retard' : '')) ->setUrl($this->view->url(['controller' => 'abonne', 'action' => 'prets'], null, true)); } - protected function _getHoldsCount($nb_reservations) { + protected function _getHoldsCount(int $nb_reservations) + { return (new Intonation_Library_Link) ->setText($this->view->_plural($nb_reservations, "", "%d réservation", "%d réservations", $nb_reservations)) - ->setAttrib('class', 'account-booking') + ->setAttrib('class', 'account_current_holds') ->setUrl($this->view->url(['controller' => 'abonne', 'action' => 'reservations'], null, true)); } - protected function _displaySimpleAccountLinks(){ + protected function _displaySimpleAccountLinks(): array + { return [(new Intonation_Library_Link) - ->setText($this->_("Voir les prêts en cours")) - ->setAttrib('class', 'account-loans') - ->setUrl($this->view->url(['controller' => 'abonne', - 'action' => 'prets'], null, true)), - (new Intonation_Library_Link) - ->setText("Voir les prêts en retard") - ->setAttrib('class', 'account-loans') - ->setUrl($this->view->url(['controller' => 'abonne', - 'action' => 'prets', - 'filter' => 'late'], - null, true)), - (new Intonation_Library_Link) - ->setText("Voir les prêts réservés par d'autres") - ->setAttrib('class', 'account-loans') - ->setUrl($this->view->url(['controller' => 'abonne', - 'action' => 'prets', - 'filter' => 'to_be_returned'], - null, true)), - (new Intonation_Library_Link) - ->setText("Voir les réservations") - ->setAttrib('class', 'account-booking') - ->setUrl($this->view->url(['controller' => 'abonne', - 'action' => 'reservations'], - null, true))]; + ->setText($this->_('Voir les prêts en cours')) + ->setAttrib('class', 'account_current_loans') + ->setUrl($this->view->url(['controller' => 'abonne', + 'action' => 'prets'], null, true)), + (new Intonation_Library_Link) + ->setText('Voir les prêts en retard') + ->setAttrib('class', 'account_late_loans') + ->setUrl($this->view->url(['controller' => 'abonne', + 'action' => 'prets', + 'filter' => 'late'], + null, true)), + (new Intonation_Library_Link) + ->setText('Voir les prêts réservés par d\'autres') + ->setAttrib('class', 'account_others_holds') + ->setUrl($this->view->url(['controller' => 'abonne', + 'action' => 'prets', + 'filter' => 'to_be_returned'], + null, true)), + (new Intonation_Library_Link) + ->setText('Voir les réservations') + ->setAttrib('class', 'account_current_holds') + ->setUrl($this->view->url(['controller' => 'abonne', + 'action' => 'reservations'], + null, true))]; } - protected function _displayLoansPagesAllLink(){ + protected function _displayLoansPagesAllLink(): Intonation_Library_Link + { return (new Intonation_Library_Link) - ->setUrl($this->_view->url(['controller'=>'abonne', - 'action'=>'prets', - 'pages' => 'all'])) - ->setText($this->_view->_('Voir tous mes prêts')) - ->setTitle($this->_('Voir tous les prêts de %s', $this->_user->getNomComplet())) - ->setAttrib('class', 'account-loans') + ->setUrl($this->view->url(['controller' => 'abonne', + 'action' => 'prets', + 'pages' => 'all'])) + ->setText($this->view->_('Voir tous mes prêts')) + ->setTitle($this->_('Voir tous les prêts de %s', + Class_Users::getIdentity()->getNomComplet())) + ->setAttrib('class', 'account_all_loans') ->alwaysDisplayText(); } - protected function _renderNumberOfDebts() : Intonation_Library_Link { - + protected function _renderNumberOfDebts(): Intonation_Library_Link + { $nb_debts = $this->_numberOfDebts(); + return (new Intonation_Library_Link) ->setText($this->view->_plural($nb_debts, '', '%d prestation à régler', '%d prestations à régler', $nb_debts)) - ->setAttrib('class', 'account-booking') + ->setAttrib('class', 'account_debts') ->setUrl($this->view->url(['controller' => 'abonne', 'action' => 'debts'], null, true)); } - protected function _numberOfDebts() : int { + protected function _numberOfDebts(): int + { $user = Class_Users::getIdentity(); Class_WebService_SIGB_EmprunteurCache::newInstance()->remove($user); $user->setFicheSigb(null); @@ -157,7 +163,8 @@ class Intonation_View_User_BorrowerLinks extends ZendAfi_View_Helper_FicheAbonne } - protected function _showDebts() : bool { + protected function _showDebts(): bool + { return Class_AdminVar::payfipDisplayedForCurrentUser() && ($this->_numberOfDebts() != 0); } diff --git a/tests/scenarios/Payfip/PayfipSubscriberTest.php b/tests/scenarios/Payfip/PayfipSubscriberTest.php index 2d164ab326e..386084fe03a 100644 --- a/tests/scenarios/Payfip/PayfipSubscriberTest.php +++ b/tests/scenarios/Payfip/PayfipSubscriberTest.php @@ -402,7 +402,7 @@ class PayfipSubscriberLoginWithDebtsTest extends PayfipSubscriberLoginTestCase { /** @test */ public function widgetLoginShouldHave_3_Prestations_a_regler() { - $this->assertXPath('//a[@href="/abonne/debts"][@class="card-link account-booking"]/div[@class="d-inline button_text text-left"][text()="3 prestations à régler"]'); + $this->assertXPath('//a[@href="/abonne/debts"][@class="card-link account_debts"]/div[@class="d-inline button_text text-left"][text()="3 prestations à régler"]'); } } @@ -416,7 +416,7 @@ class PayfipSubscriberLoginWithDebtsAndTestModeTest extends PayfipSubscriberLogi /** @test */ public function widgetLoginShouldHave_3_Prestations_a_regler() { - $this->assertNotXPath('//a[@href="/abonne/debts"][@class="card-link account-booking"]/div[@class="d-inline button_text text-left"][text()="3 prestations à régler"]'); + $this->assertNotXPath('//a[@href="/abonne/debts"][@class="card-link account_debts"]/div[@class="d-inline button_text text-left"][text()="3 prestations à régler"]'); } } @@ -430,7 +430,7 @@ class PayfipSubscriberLoginWithDebtsAndHiddenTest extends PayfipSubscriberLoginT /** @test */ public function widgetLoginShouldHave_3_Prestations_a_regler() { - $this->assertNotXPath('//a[@href="/abonne/debts"][@class="card-link account-booking"]/div[@class="d-inline button_text text-left"][text()="3 prestations à régler"]'); + $this->assertNotXPath('//a[@href="/abonne/debts"][@class="card-link account_debts"]/div[@class="d-inline button_text text-left"][text()="3 prestations à régler"]'); } } @@ -444,7 +444,7 @@ class PayfipTesterWithDebtsAndTestModeAndHiddenTest extends PayfipSubscriberLogi /** @test */ public function widgetLoginShouldHave_3_Prestations_a_regler() { - $this->assertXPath('//a[@href="/abonne/debts"][@class="card-link account-booking"]/div[@class="d-inline button_text text-left"][text()="3 prestations à régler"]'); + $this->assertXPath('//a[@href="/abonne/debts"][@class="card-link account_debts"]/div[@class="d-inline button_text text-left"][text()="3 prestations à régler"]'); } } @@ -576,7 +576,7 @@ class PayfipSubscriberBorrowerLinksTest extends PayfipSubscriberLoginTestCase { /** @test */ public function accountDebtsShouldContainsTroisPrestations() { - $this->assertXPathContentContains('//a[@href="/abonne/debts"][@class="card-link account-booking"]/div[@class="d-inline button_text text-left"]', + $this->assertXPathContentContains('//a[@href="/abonne/debts"][@class="card-link account_debts"]/div[@class="d-inline button_text text-left"]', '3 prestations à régler'); } } diff --git a/tests/scenarios/Payfip/PayfipTemplatesAbonneTest.php b/tests/scenarios/Payfip/PayfipTemplatesAbonneTest.php index 77a3183500a..2fcb6870074 100644 --- a/tests/scenarios/Payfip/PayfipTemplatesAbonneTest.php +++ b/tests/scenarios/Payfip/PayfipTemplatesAbonneTest.php @@ -308,7 +308,7 @@ class PayfipTemplatesAbonneRefreshPayfipandIlsUpdatedTest extends PayfipTemplate /** @test */ public function debtsShouldBeDisplayedOnLoginWidget() { - $this->assertXPath('//a[@href="/abonne/debts"][@class="card-link account-booking"]/div[@class="d-inline button_text text-left"][text()="3 prestations à régler"]'); + $this->assertXPath('//a[@href="/abonne/debts"][@class="card-link account_debts"]/div[@class="d-inline button_text text-left"][text()="3 prestations à régler"]'); } } @@ -475,7 +475,7 @@ class PayfipTemplatesAbonneDebts2SitesDisplayTestCase extends PayfipTemplatesAbo /** @test */ public function debtsShouldBeDisplayedOnLoginWidget() { $this->dispatch('/index/index'); - $this->assertXPath('//a[@href="/abonne/debts"][@class="card-link account-booking"]/div[@class="d-inline button_text text-left"][text()="2 prestations à régler"]'); + $this->assertXPath('//a[@href="/abonne/debts"][@class="card-link account_debts"]/div[@class="d-inline button_text text-left"][text()="2 prestations à régler"]'); } @@ -521,7 +521,7 @@ class PayfipTemplatesAbonneDebts2SitesOneAvailableDisplayTestCase extends Payfip public function debtsShouldBeDisplayedOnLoginWidget() { $this->dispatch('/index/index'); - $this->assertXPath('//a[@href="/abonne/debts"][@class="card-link account-booking"]/div[@class="d-inline button_text text-left"][text()="1 prestation à régler"]'); + $this->assertXPath('//a[@href="/abonne/debts"][@class="card-link account_debts"]/div[@class="d-inline button_text text-left"][text()="1 prestation à régler"]'); } diff --git a/tests/scenarios/Templates/TemplatesAbonnePretsTest.php b/tests/scenarios/Templates/TemplatesAbonnePretsTest.php index 233d82d2e53..8efd442970c 100644 --- a/tests/scenarios/Templates/TemplatesAbonnePretsTest.php +++ b/tests/scenarios/Templates/TemplatesAbonnePretsTest.php @@ -225,28 +225,28 @@ class TemplatesAbonnePretsIndexTest extends TemplatesAbonnePretsAjaxLoansPaginat /** @test */ public function boitedefaultLoginShouldContainsLinkPretsEnCours() { - $this->assertXPathContentContains('//div[@class="default_login"]//a[contains(@class,"account-loans")][@href="/abonne/prets"]',"Voir les prêts en cours"); + $this->assertXPathContentContains('//div[@class="default_login"]//a[contains(@class, "account_current_loans")][@href="/abonne/prets"]', "Voir les prêts en cours"); } /** @test */ public function boitedefaultLoginShouldContainsLinkPretsEnRetard() { - $this->assertXPathContentContains('//div[@class="default_login"]//a[contains(@class,"account-loans")][@href="/abonne/prets/filter/late"]',"Voir les prêts en retard"); + $this->assertXPathContentContains('//div[@class="default_login"]//a[contains(@class, "account_late_loans")][@href="/abonne/prets/filter/late"]', "Voir les prêts en retard"); } /** @test */ public function boitedefaultLoginShouldContainsLinkPretsReserves() { - $this->assertXPathContentContains('//div[@class="default_login"]//a[contains(@class,"account-loans")][@href="/abonne/prets/filter/to_be_returned"]',"Voir les prêts réservés par d'autres"); + $this->assertXPathContentContains('//div[@class="default_login"]//a[contains(@class, "account_others_holds")][@href="/abonne/prets/filter/to_be_returned"]', "Voir les prêts réservés par d'autres"); } /** @test */ public function boitedefaultLoginShouldContainsLinkResrvations() { - $this->assertXPathContentContains('//div[@class="default_login"]//a[contains(@class,"account-booking")][@href="/abonne/reservations"]',"Voir les réservations"); + $this->assertXPathContentContains('//div[@class="default_login"]//a[contains(@class, "account_current_holds")][@href="/abonne/reservations"]', "Voir les réservations"); } } diff --git a/tests/scenarios/Templates/TemplatesBorrowerTest.php b/tests/scenarios/Templates/TemplatesBorrowerTest.php new file mode 100644 index 00000000000..40436dc54c2 --- /dev/null +++ b/tests/scenarios/Templates/TemplatesBorrowerTest.php @@ -0,0 +1,75 @@ +<?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 + */ + +require_once 'TemplatesTest.php'; + +/* @see : https://forge.afi-sa.net/issues/202507 */ +class TemplatesBorrowerWithPagesLoansTest extends TemplatesIntonationTestCase +{ + + public function setUp() + { + parent::setUp(); + + $patrick = Class_WebService_SIGB_Emprunteur::newInstance(5, 'patrick') + ->empruntsAddAll([Class_WebService_SIGB_Emprunt::newInstanceWithEmptyExemplaire() + ->setDateRetour('23/12/2056'), + + Class_WebService_SIGB_Emprunt::newInstanceWithEmptyExemplaire() + ->setDateRetour('3/2/2056'), + + Class_WebService_SIGB_Emprunt::newInstanceWithEmptyExemplaire() + ->setDateRetour('23/1/1999')]); + + $this->fixture(Class_Bib::class, + ['id' => 34]); + + $comm_params = ['url_serveur' => 'tests/fixtures/koha.wsdl', + 'allow_hold_available_items' => true, + 'loans_per_page' => 2]; + + ZendAfi_Auth::getInstance() + ->logUser($this->fixture(Class_Users::class, + ['id' => 5, + 'login' => 'patrick', + 'password' => '1', + 'idabon' => 456, + 'role_level' => ZendAfi_Acl_AdminControllerRoles::ABONNE_SIGB, + 'id_site' => 34, + 'int_bib' => $this->fixture(Class_IntBib::class, + ['id' => 34, + 'comm_sigb' => Class_IntBib::COM_KOHA, + 'comm_params' => $comm_params]), + 'fiche_sigb' => ['fiche' => $patrick]])); + + $intonation_profil = Class_Profil::find(72); + $intonation_profil->setAccessLevel(0); + + $this->dispatch('/opac/index/index/id_profil/72'); + } + + + /** @test */ + public function linkClassAccountLoansShouldHaveTitleVoirTousLesPretsDePatrick() + { + $this->assertXPath('//a[contains(@class, "account_all_loans")][@title="Voir tous les prêts de patrick"]'); + } +} -- GitLab