From 4070e6a34b5495cef592b08227eaf9013b51e873 Mon Sep 17 00:00:00 2001 From: Henri-Damien LAURENT <hdlaurent@afi-sa.fr> Date: Fri, 21 Aug 2020 17:09:34 +0200 Subject: [PATCH] hotline#115306: Bootstrap : Performance Improvements for Issue Page for User at OPAC --- VERSIONS_HOTLINE/115306 | 1 + .../opac/controllers/AbonneController.php | 32 ++- .../opac/views/scripts/abonne/loans.phtml | 2 + .../View/Helper/Abonne/LoansHistoryBoard.php | 2 +- .../templates/Intonation/Library/Settings.php | 1 + .../Intonation/Library/View/Wrapper/User.php | 4 +- .../View/Wrapper/User/RichContent/Loans.php | 2 +- .../Wrapper/User/RichContent/LoansHistory.php | 53 +++++ .../Intonation/Library/Widget/Login/View.php | 6 +- .../Intonation/View/Abonne/AjaxLoans.php | 9 - .../View/Abonne/AjaxLoansHistory.php | 61 ++++++ .../Intonation/View/Abonne/LoansBoard.php | 23 ++- .../View/Abonne/LoansHistoryList.php | 42 ++++ .../Intonation/View/Abonne/LoansList.php | 20 +- tests/scenarios/Templates/TemplatesTest.php | 193 ++++++++++++++++-- 15 files changed, 410 insertions(+), 41 deletions(-) create mode 100644 VERSIONS_HOTLINE/115306 create mode 100644 application/modules/opac/views/scripts/abonne/loans.phtml create mode 100644 library/templates/Intonation/Library/View/Wrapper/User/RichContent/LoansHistory.php create mode 100644 library/templates/Intonation/View/Abonne/AjaxLoansHistory.php create mode 100644 library/templates/Intonation/View/Abonne/LoansHistoryList.php diff --git a/VERSIONS_HOTLINE/115306 b/VERSIONS_HOTLINE/115306 new file mode 100644 index 00000000000..68eac48810d --- /dev/null +++ b/VERSIONS_HOTLINE/115306 @@ -0,0 +1 @@ + - ticket #115306 : [Magasin de thèmes] - Affichage TRES LENT du compte / des prêts \ No newline at end of file diff --git a/application/modules/opac/controllers/AbonneController.php b/application/modules/opac/controllers/AbonneController.php index 0d2107e3ed4..6125b34d2a3 100644 --- a/application/modules/opac/controllers/AbonneController.php +++ b/application/modules/opac/controllers/AbonneController.php @@ -429,6 +429,7 @@ class AbonneController extends ZendAfi_Controller_Action { 'end_issue_date' => $this->_getPost('end_issue_date')]); $cards = new Class_User_Cards($this->_user); + $loans = $cards->getLoansWithOutPNB($this->_request->getParams()); $fiche = $this->_user->getFicheSigb(); $error = (isset($fiche['error']) && $fiche['error']) @@ -492,6 +493,8 @@ class AbonneController extends ZendAfi_Controller_Action { } + + public function reservationsAction() { $cards = new Class_User_Cards($this->_user); @@ -1335,6 +1338,22 @@ class AbonneController extends ZendAfi_Controller_Action { } + public function loansAction() { + if($this->_request->isPost()) + return $this->_redirectToRefererWithNewParams(['onhold' => $this->_getPost('onhold'), + 'start_date_retour' => $this->_getPost('start_date_retour'), + 'end_date_retour' => $this->_getPost('end_date_retour'), + 'start_issue_date' => $this->_getPost('start_issue_date'), + 'end_issue_date' => $this->_getPost('end_issue_date')]); + + + $this->view->config = new Class_Entity(['User' => $this->_user, + 'Profile' => Class_Profil::getCurrentProfil(), + 'RequestParams' => $this->_request->getParams()]); + + } + + public function addCardAction() { $this->view->titre = $this->_('Ajouter une carte'); @@ -1945,11 +1964,16 @@ class AbonneController extends ZendAfi_Controller_Action { public function ajaxLoansAction() { session_write_close(); - - $callback = function() { - return $this->view->abonne_AjaxLoans($this->_user); + $patron = $this->_user->getEmprunteur(); + $patron->ensureService($this->_user)->save(); + $cards = new Class_User_Cards($this->_user); + $isHistory = $this->_request->getParam('history'); + $callback = function() use ($isHistory){ + return $isHistory + ? $this->view->abonne_AjaxLoansHistory(new Class_Entity(['User' => $this->_user, + 'RequestParams' => $this->_request->getParams()])) + : $this->view->abonne_AjaxLoans($this->_user); }; - return $this->_helper->ajax($callback); } diff --git a/application/modules/opac/views/scripts/abonne/loans.phtml b/application/modules/opac/views/scripts/abonne/loans.phtml new file mode 100644 index 00000000000..c3ffc697a76 --- /dev/null +++ b/application/modules/opac/views/scripts/abonne/loans.phtml @@ -0,0 +1,2 @@ +<?php +echo $this->abonne_LoansBoard($this->config); diff --git a/library/ZendAfi/View/Helper/Abonne/LoansHistoryBoard.php b/library/ZendAfi/View/Helper/Abonne/LoansHistoryBoard.php index ffeee07507f..ad205b315d6 100644 --- a/library/ZendAfi/View/Helper/Abonne/LoansHistoryBoard.php +++ b/library/ZendAfi/View/Helper/Abonne/LoansHistoryBoard.php @@ -24,7 +24,7 @@ class ZendAfi_View_Helper_Abonne_LoansHistoryBoard extends ZendAfi_View_Helper_A public function abonne_LoansHistoryBoard($config) { $this->_config = $config; - $loans = $config->getLoans(); + $loans = $config->getLoansHistory(); $user = $config->getUser(); $this->_profile = $profile = $config->getProfile(); $error = $config->getError(); diff --git a/library/templates/Intonation/Library/Settings.php b/library/templates/Intonation/Library/Settings.php index 8407009ca8b..282f4649d18 100644 --- a/library/templates/Intonation/Library/Settings.php +++ b/library/templates/Intonation/Library/Settings.php @@ -235,6 +235,7 @@ class Intonation_Library_Settings extends Intonation_System_Abstract { 'icons_map_library' => ['author' => 'class fas fa-user', 'search_more' => 'class fas fa-list', 'library' => 'class fas fa-landmark', + 'history' => 'class fas fa-history', 'available' => 'class far fa-check-circle', 'not-available' => 'class far fa-times-circle', 'readed' => 'class fas fa-check-circle text-success', diff --git a/library/templates/Intonation/Library/View/Wrapper/User.php b/library/templates/Intonation/Library/View/Wrapper/User.php index add2dfdc787..71e97806ee0 100644 --- a/library/templates/Intonation/Library/View/Wrapper/User.php +++ b/library/templates/Intonation/Library/View/Wrapper/User.php @@ -156,7 +156,7 @@ class Intonation_Library_View_Wrapper_User extends Intonation_Library_View_Wrapp $badges [] = ((new Intonation_Library_Badge) ->setTag('a') ->setUrl($this->_view->url(['controller' => 'abonne', - 'action' => 'prets'])) + 'action' => 'loans'])) ->setClass('info') ->setImage(Class_Template::current() ->getIco($this->_view, @@ -171,7 +171,7 @@ class Intonation_Library_View_Wrapper_User extends Intonation_Library_View_Wrapp $badges [] = ((new Intonation_Library_Badge) ->setTag('a') ->setUrl($this->_view->url(['controller' => 'abonne', - 'action' => 'prets'])) + 'action' => 'loans'])) ->setClass('danger') ->setImage(Class_Template::current() ->getIco($this->_view, diff --git a/library/templates/Intonation/Library/View/Wrapper/User/RichContent/Loans.php b/library/templates/Intonation/Library/View/Wrapper/User/RichContent/Loans.php index c9f9747018f..63c031d8ff9 100644 --- a/library/templates/Intonation/Library/View/Wrapper/User/RichContent/Loans.php +++ b/library/templates/Intonation/Library/View/Wrapper/User/RichContent/Loans.php @@ -48,7 +48,7 @@ class Intonation_Library_View_Wrapper_User_RichContent_Loans extends Intonation_ public function getNavUrl() { return ['controller' => 'abonne', - 'action' => 'prets']; + 'action' => 'loans']; } diff --git a/library/templates/Intonation/Library/View/Wrapper/User/RichContent/LoansHistory.php b/library/templates/Intonation/Library/View/Wrapper/User/RichContent/LoansHistory.php new file mode 100644 index 00000000000..5dbc57284a0 --- /dev/null +++ b/library/templates/Intonation/Library/View/Wrapper/User/RichContent/LoansHistory.php @@ -0,0 +1,53 @@ +<?php +/** + * Copyright (c) 2012-2019, 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 Intonation_Library_View_Wrapper_User_RichContent_LoansHistory extends Intonation_Library_View_Wrapper_User_RichContent_Loans { + + protected $_is_visible = false; + + + public function getTitle() { + return $this->_('Mon historique de prêts'); + } + + + public function getContent() { + if ($this->_content) + return $this->_content; + + return $this->_content = $this->_view->renderAjax('abonne', + 'ajax-loans', + ['id' => $this->_model->getId(), + 'history' => 1], + $this->_getJsCallback()); + } + + + public function getNavIco() { + return 'class fas fa-book'; + } + + + public function getNavTitle() { + return $this->_('Mon historique de prêts'); + } +} diff --git a/library/templates/Intonation/Library/Widget/Login/View.php b/library/templates/Intonation/Library/Widget/Login/View.php index 4a3c0949e1f..f3d991218eb 100644 --- a/library/templates/Intonation/Library/Widget/Login/View.php +++ b/library/templates/Intonation/Library/Widget/Login/View.php @@ -189,7 +189,7 @@ class IntonationLoginRenderDefault extends IntonationLoginRenderAbstract { if (!$cards->isEmpty()) { $loans = $cards->hasPagedLoans() ? [$this->_view->tagAnchor(['controller' => 'abonne', - 'action' => 'prets', + 'action' => 'loans', 'pages' => 'all'], $this->view->_('Voir tous mes prêts'), ['class' => 'account-loans'])] @@ -256,7 +256,7 @@ class IntonationLoginRenderInline extends IntonationLoginRenderAbstract { if (!$cards->isEmpty()) { $loans = $cards->hasPagedLoans() ? [$this->_view->tagAnchor(['controller' => 'abonne', - 'action' => 'prets', + 'action' => 'loans', 'pages' => 'all'], $this->view->_('Voir tous mes prêts'), ['class' => 'account-loans'])] @@ -330,7 +330,7 @@ class IntonationLoginRenderToggle extends IntonationLoginRenderAbstract { if (!$cards->isEmpty()) { $loans = $cards->hasPagedLoans() ? [$this->_view->tagAnchor(['controller' => 'abonne', - 'action' => 'prets', + 'action' => 'loans', 'pages' => 'all'], $this->view->_('Voir tous mes prêts'), ['class' => 'account-loans'])] diff --git a/library/templates/Intonation/View/Abonne/AjaxLoans.php b/library/templates/Intonation/View/Abonne/AjaxLoans.php index b89e4c5bd60..1937d4c68d7 100644 --- a/library/templates/Intonation/View/Abonne/AjaxLoans.php +++ b/library/templates/Intonation/View/Abonne/AjaxLoans.php @@ -60,10 +60,6 @@ class Intonation_View_Abonne_AjaxLoans extends ZendAfi_View_Helper_BaseHelper { 'Loans' => $cards->getPNBLoans()])) : ''; - $history = $this->view->abonne_LoansList(new Class_Entity(['Profile' => Class_Profil::getCurrentProfil(), - 'RequestParams' => [], - 'User' => $this->_model, - 'Loans' => $cards->getLoansHistory([])])); $html = []; @@ -75,11 +71,6 @@ class Intonation_View_Abonne_AjaxLoans extends ZendAfi_View_Helper_BaseHelper { $this->view->tag('h3', $this->_('Prêts numériques en cours')) . $pnb); - if ($history) - $html [] = $this->view->div(['class' => 'col-12'], - $this->view->tag('h3', $this->_('Historique des prêts')) - . $history); - return $this->view->grid(implode($html)); } } \ No newline at end of file diff --git a/library/templates/Intonation/View/Abonne/AjaxLoansHistory.php b/library/templates/Intonation/View/Abonne/AjaxLoansHistory.php new file mode 100644 index 00000000000..d5640766e3c --- /dev/null +++ b/library/templates/Intonation/View/Abonne/AjaxLoansHistory.php @@ -0,0 +1,61 @@ +<?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 Intonation_View_Abonne_AjaxLoansHistory extends ZendAfi_View_Helper_BaseHelper { + + protected $_model, $_ajax = true; + + + public function abonne_AjaxLoansHistory($config) { + if (! $user = $config->getUser()) + return ''; + + $this->_model = $user; + + $cards = new Class_User_Cards($this->_model); + $fiche = $this->_model->getFicheSigb(); + $loans = $cards->getLoansHistory(); + $error = (isset($fiche['error']) && $fiche['error']) + ? $fiche['error'] + : ''; + + return $this->_getContent((new Class_Entity(['Cards' => $cards, + 'User' => $this->_model, + 'Error' => $error, + 'Loans' => $loans, + 'Profile' => Class_Profil::getCurrentProfil(), + 'RequestParams' => $config->getRequestParams()]))); + } + + + protected function _getContent($settings) { + $cards = $settings->getCards(); + $history = $this->view->abonne_LoansHistoryList($settings); + + $html = []; + + $html [] = $this->view->div(['class' => 'col-12'], + $history); + + return $this->view->grid(implode($html)); + } +} \ No newline at end of file diff --git a/library/templates/Intonation/View/Abonne/LoansBoard.php b/library/templates/Intonation/View/Abonne/LoansBoard.php index db42c9ad69d..945e6090091 100644 --- a/library/templates/Intonation/View/Abonne/LoansBoard.php +++ b/library/templates/Intonation/View/Abonne/LoansBoard.php @@ -22,10 +22,29 @@ class Intonation_View_Abonne_LoansBoard extends Intonation_View_Abonne { - protected $_show_current_section = 'user_loans'; + protected $_show_current_section = 'user_loans', $_config; public function abonne_LoansBoard($config) { - return $this->_renderSection($config->getUser()); + $this->_config = $config; + + + return $this->_renderSection($this->_config->getUser()); + } + + protected function _hookOn($rich_content) { + if (!isset($this->_config->getRequestParams()['history'])) + return; + + $sections = $rich_content->getSections(); + + $sections [Intonation_Library_View_Wrapper_User_RichContent::LOANS] = (new Intonation_Library_View_Wrapper_User_RichContent_LoansHistory) + ->setModel($this->view->user) + ->setView($this->view) + ->beActive() + ->beVisible(); + + $rich_content->setSections($sections); } + } \ No newline at end of file diff --git a/library/templates/Intonation/View/Abonne/LoansHistoryList.php b/library/templates/Intonation/View/Abonne/LoansHistoryList.php new file mode 100644 index 00000000000..2b9f98ed20f --- /dev/null +++ b/library/templates/Intonation/View/Abonne/LoansHistoryList.php @@ -0,0 +1,42 @@ +<?php +/** + * Copyright (c) 2012-2019, 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 Intonation_View_Abonne_LoansHistoryList extends Intonation_View_Abonne_LoansList { + protected $_config; + + public function abonne_LoansHistoryList($config) { + return $this->abonne_LoansList($config); + } + + + protected function _getActions() { + return [ new Intonation_Library_Link(['Url' => ['controller' => 'abonne', + 'action' => 'loans', + 'history' => null + ], + 'Text' => $this->_('Mes prêts'), + 'Title' => $this->_('Voir mes prêts'), + 'Image' => Class_Template::current()->getIco($this->view, + 'loan', + 'library')]) ]; + } +} diff --git a/library/templates/Intonation/View/Abonne/LoansList.php b/library/templates/Intonation/View/Abonne/LoansList.php index 2ddcf179789..ca04a6c6c10 100644 --- a/library/templates/Intonation/View/Abonne/LoansList.php +++ b/library/templates/Intonation/View/Abonne/LoansList.php @@ -45,8 +45,25 @@ class Intonation_View_Abonne_LoansList extends ZendAfi_View_Helper_BaseHelper { if (!$loans) return ''; + $actions = $this->_getActions(); + + return $this->view->renderCollection(new Storm_Collection($loans), $actions); + } + + + protected function _getActions() { $actions = []; + $actions [] = new Intonation_Library_Link(['Url' => ['controller' => 'abonne', + 'action' => 'loans', + 'history' => 1 + ], + 'Text' => $this->_('Mon historique de prêts'), + 'Title' => $this->_('Voir mon historique de prêts'), + 'Image' => Class_Template::current()->getIco($this->view, + 'loan', + 'library')]); + if ($this->_config->getExtendAll()) $actions [] = new Intonation_Library_Link(['Url' => ['controller' => 'abonne', 'action' => 'prolongerPret', @@ -56,7 +73,6 @@ class Intonation_View_Abonne_LoansList extends ZendAfi_View_Helper_BaseHelper { 'Image' => Class_Template::current()->getIco($this->view, 'extend-loan', 'library')]); - - return $this->view->renderCollection(new Storm_Collection($loans), $actions); + return $actions; } } diff --git a/tests/scenarios/Templates/TemplatesTest.php b/tests/scenarios/Templates/TemplatesTest.php index e162b8678b1..e83e2ca3971 100644 --- a/tests/scenarios/Templates/TemplatesTest.php +++ b/tests/scenarios/Templates/TemplatesTest.php @@ -2061,6 +2061,7 @@ class TemplatesDispatchIntonationAdvancedSearchTest extends TemplatesIntonationT abstract class TemplatesIntonationAccountTestCase extends TemplatesIntonationTestCase { + protected $_mock_emprunts, $_emprunteur; public function setUp() { parent::setUp(); @@ -2162,19 +2163,21 @@ abstract class TemplatesIntonationAccountTestCase extends TemplatesIntonationTes 'libelle' => 'Istres', 'id_origine' => 'IST']); - $emprunteur = new Class_WebService_SIGB_Emprunteur('1234', 'Florence'); - $emprunteur + + $this->_emprunteur = new Class_WebService_SIGB_Emprunteur('1234', 'Florence'); + $this->_emprunteur ->setLibraryCode('IST') ->empruntsAddAll([$potter, $alice]) ->reservationsAddAll([$dobby]); $current_user = Class_Users::getIdentity(); $current_user + ->setExtendAll(true) ->setPassword('test') ->setIdabon(123456) ->setDateFin('2020/01/01') ->setFicheSigb(['type_comm' => 2, - 'fiche' => $emprunteur, + 'fiche' => $this->_emprunteur, 'erreur' => '']) ->setPseudo('Paul') ->beAbonneSIGB(); @@ -2440,20 +2443,6 @@ class TemplatesDispatchAbonneLoansTest extends TemplatesIntonationAccountTestCas } - /** @test */ - public function shouldContainsLoanAlice() { - $this->dispatch('/opac/abonne/ajax-loans/id_profil/72'); - $this->assertXPathContentContains('//div', 'Alice'); - } - - - /** @test */ - public function shouldContainsLoanDrHouse() { - $this->dispatch('/opac/abonne/ajax-loans/id_profil/72'); - $this->assertXPathContentContains('//div', 'Dr House'); - } - - /** @test */ public function page2ShouldContainsSearchInputWithMd5Key() { Storm_Cache::beVolatile(); @@ -2568,6 +2557,176 @@ class TemplatesDispatchAbonneLoansTest extends TemplatesIntonationAccountTestCas +class TemplatesDispatchAbonneAjaxLoansTest extends TemplatesIntonationAccountTestCase { + public function setUp(){ + parent::setUp(); + $this->dispatch('/opac/abonne/ajax-loans/id_profil/72'); + } + + /** @test */ + public function ajaxLoanAliceShouldDisplayButtonToutProlonger() { + $this->assertXPathContentContains('//div[contains(@class,"button_text")]', 'Tout prolonger'); + } + + + /** @test */ + public function ajaxLoansShouldDisplayButtonMonHistorique() { + $this->assertXPathContentContains('//div[contains(@class,"button_text")]', utf8_encode('Mon historique de prêts')); + } + + + /** @test */ + public function shouldContainsLoanAlice() { + $this->assertXPathContentContains('//div', 'Alice'); + } + + + /** @test */ + public function shouldContainsLoanDrHouse() { + $this->assertXPathContentContains('//div', 'Dr House'); + } + + + /** @test */ + public function ajaxLoansShouldNotDisplayTitleHistoriqueDesPrets() { + $this->assertNotXPathContentContains('//h3', 'Historique des prêts'); + } + + + /** @test */ + public function shouldNotContainsLoanHistoryPottifar() { + $this->assertNotXPathContentContains('//div', 'Pottifar'); + } +} + + + + + +class TemplatesDispatchAbonneMonHistoriqueTest extends TemplatesIntonationAccountTestCase { + public function setUp(){ + parent::setUp(); + + $pottifar_old = new Class_WebService_SIGB_LoansHistory($this->_emprunteur); + $notice_unimarc = (new Class_NoticeUnimarc_Fluent); + $notice_unimarc->newZone()->label('200')->addChild('a', 'Pottifar'); + + $notice = $this->fixture('Class_Notice', + ['id' => 890, + 'clef_alpha' => 'MYSUPERkey', + 'unimarc' => $notice_unimarc->render(), + 'facettes' => 'M8897 T1 B3 A18 Lfre']); + + $exemplaire = $this->fixture('Class_Exemplaire', + ['id' => 891, + 'id_origine' => 1234, + 'code_barres' => 456, + 'id_int_bib' => 1, + 'zone995' => serialize([['clef' => 'a', 'valeur' => 'PottifarItem']]), + 'notice' => $notice]); + + $pottifar_old_issue = new Class_WebService_SIGB_Emprunt('42', new Class_WebService_SIGB_Exemplaire(456)); + $pottifar_old_issue + ->setCodeBarre(456) + ->setDateRetour('10/01/1981') + ->setIssueDate('1981-01-01') + ->beReturned() + ->getExemplaire() + ->setTitre('Pottifar') + ->setExemplaireOPAC($exemplaire) + ->setNoticeOPAC($notice); + + $pottifar_old->addLoan($pottifar_old_issue); + + $this->_mock_emprunts = $this->mock() + ->whenCalled('loansHistory') + ->answers($pottifar_old) + ->whenCalled('getLoansPerPage') + ->answers(3) + ->whenCalled('providesPagedLoans') + ->answers(false); + + $this->_emprunteur->setService($this->_mock_emprunts); + + $this->dispatch('/opac/abonne/loans/history/1/id_profil/72'); + } + + + + /** @test */ + public function pageShouldDisplayTitleMonHistoriqueDePrets() { + $this->assertXPathContentContains('//h2//span', 'Mon historique de prêts', $this->_response->getBody()); + } +} + + + + +class TemplatesDispatchAbonneLoansWithHistoryTest extends TemplatesIntonationAccountTestCase { + public function setUp(){ + parent::setUp(); + + $pottifar_old = new Class_WebService_SIGB_LoansHistory($this->_emprunteur); + $notice_unimarc = (new Class_NoticeUnimarc_Fluent); + $notice_unimarc->newZone()->label('200')->addChild('a', 'Pottifar'); + + $notice = $this->fixture('Class_Notice', + ['id' => 890, + 'clef_alpha' => 'MYSUPERkey', + 'unimarc' => $notice_unimarc->render(), + 'facettes' => 'M8897 T1 B3 A18 Lfre']); + + $exemplaire = $this->fixture('Class_Exemplaire', + ['id' => 891, + 'id_origine' => 1234, + 'code_barres' => 456, + 'id_int_bib' => 1, + 'zone995' => serialize([['clef' => 'a', 'valeur' => 'PottifarItem']]), + 'notice' => $notice]); + + $pottifar_old_issue = new Class_WebService_SIGB_Emprunt('42', new Class_WebService_SIGB_Exemplaire(456)); + $pottifar_old_issue + ->setCodeBarre(456) + ->setDateRetour('10/01/1981') + ->setIssueDate('1981-01-01') + ->beReturned() + ->getExemplaire() + ->setTitre('Pottifar') + ->setExemplaireOPAC($exemplaire) + ->setNoticeOPAC($notice); + + $pottifar_old->addLoan($pottifar_old_issue); + + $this->_mock_emprunts = $this->mock() + ->whenCalled('loansHistory') + ->answers($pottifar_old) + ->whenCalled('getLoansPerPage') + ->answers(3) + ->whenCalled('saveEmprunteur') + ->answers(null) + ->whenCalled('providesPagedLoans') + ->answers(false); + + $this->_emprunteur->setService($this->_mock_emprunts); + + + $this->dispatch('/opac/abonne/ajax-loans/history/1/id_profil/72'); + } + + + /** @test */ + public function pageShouldContainsPottifar() { + $this->assertXPathContentContains('//div','Pottifar', $this->_response->getBody()); + } + + + /** @test */ + public function pageShouldDisplayButtonMesPrets() { + $this->assertXPathContentContains('//div[contains(@class,"button_text")]', utf8_encode('Mes prêts'), $this->_response->getBody()); + } +} + + class TemplatesDispatchAbonneHoldsTest extends TemplatesIntonationAccountTestCase { /** @test */ public function holdsDobbyPotterShouldBeDisplay() { -- GitLab