diff --git a/VERSIONS_HOTLINE/148741 b/VERSIONS_HOTLINE/148741 new file mode 100644 index 0000000000000000000000000000000000000000..fed4b3334f5d8d858e21e31762b72d0028a39804 --- /dev/null +++ b/VERSIONS_HOTLINE/148741 @@ -0,0 +1 @@ + - correctif #148741 : PNB : Les login et cartes lecteurs sont intégrées dans l'export CSV des prêts Dilicom. Les 5 prêts historiques sont affichés en front en respectant le RGPD. \ No newline at end of file diff --git a/library/Class/Loan/Pnb.php b/library/Class/Loan/Pnb.php index 6fd89b580303697af8755ec3ad25f66bda6d6c6e..3a179a8b78a5b661d13ead5d0229d26656e084aa 100644 --- a/library/Class/Loan/Pnb.php +++ b/library/Class/Loan/Pnb.php @@ -20,6 +20,8 @@ */ class Class_Loan_PnbLoader extends Storm_Model_Loader { + const + CNIL_DAYS_MAX_RETENTION = -122; public function findAllOngoingOfUser($user) { if (!$user) @@ -81,7 +83,9 @@ class Class_Loan_PnbLoader extends Storm_Model_Loader { return Class_Loan_Pnb::findAllBy(['order_line_id' => $item->getOrderLineId(), 'order' => 'expected_return_date desc', 'limit' => 5, - 'where' => sprintf('expected_return_date <= "%s"', $this->_getDate())]); + 'where' => sprintf('expected_return_date <= "%s" and expected_return_date >= "%s"', + $this->_getDate(), + $this->_getCNILMaxRetentionDate())]); } @@ -101,9 +105,14 @@ class Class_Loan_PnbLoader extends Storm_Model_Loader { } - protected function _getDate() { + protected function _getDate() :string { return Class_Loan_Pnb::getTimeSource()->dateFormat('Y-m-d H:i:s'); } + + + protected function _getCNILMaxRetentionDate() :string { + return Class_Loan_Pnb::addDaysToCurrentDate(static::CNIL_DAYS_MAX_RETENTION); + } } @@ -202,6 +211,20 @@ class Class_Loan_Pnb extends Storm_Model_Abstract { } + public function getUserLogin() :string { + if ($user = $this->getUser()) + return $user->getLogin(); + return ''; + } + + + public function getUserIdabon() :string { + if ($user = $this->getUser()) + return $user->getIdabon(); + return ''; + } + + public function getDateRetour() { return $this->getExpectedReturnDate(); } diff --git a/library/Class/TableDescription/PNBLoans.php b/library/Class/TableDescription/PNBLoans.php index 97af36975df1acb508f2743e6382e1f9ab8ae7d4..9e06943066e4c5f6ce1dee64aae42eaba1ee18ea 100644 --- a/library/Class/TableDescription/PNBLoans.php +++ b/library/Class/TableDescription/PNBLoans.php @@ -36,7 +36,10 @@ class Class_TableDescription_PNBLoans extends Class_TableDescription { ->addColumn($this->_('Genre'), 'first_kind') ->addColumn($this->_('Section'), 'first_section') ->addColumn($this->_('Catégorie'), 'category') - ->addColumn($this->_('Bibliothèque'), 'bibliotheque'); + ->addColumn($this->_('Bibliothèque'), 'bibliotheque') + ->addColumn($this->_('Login Emprunteur'), 'user_login') + ->addColumn($this->_('Carte Emprunteur'), 'user_idabon') + ->addColumn($this->_('orderid'), 'order_line_id'); } diff --git a/library/ZendAfi/View/Helper/Album/Loans.php b/library/ZendAfi/View/Helper/Album/Loans.php index 5b59a058c401cf3e12069a9145b88a72c4666518..b4e85bdc12d9263d692362ed534d1000687d14c8 100644 --- a/library/ZendAfi/View/Helper/Album/Loans.php +++ b/library/ZendAfi/View/Helper/Album/Loans.php @@ -22,7 +22,7 @@ class ZendAfi_View_Helper_Album_Loans extends ZendAfi_View_Helper_BaseHelper { public function Album_Loans($item) { - if(!$loans = Class_Loan_Pnb::findAllOngoingOfItem($item)) + if(!$loans = $this->_getLoans($item)) return $this->_tag('p', $this->_getEmptyMessage(), ['class' => 'error']); @@ -42,7 +42,12 @@ class ZendAfi_View_Helper_Album_Loans extends ZendAfi_View_Helper_BaseHelper { } - protected function _getEmptyMessage() { + protected function _getLoans($item) : Array{ + return Class_Loan_Pnb::findAllOngoingOfItem($item); + } + + + protected function _getEmptyMessage() : string { return $this->_('Aucun prêt en cours'); } } \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/Album/OldLoans.php b/library/ZendAfi/View/Helper/Album/OldLoans.php index c81f31dd45aae2fd903f4ae3d94b3ddfd9151147..faf96c4fedc1e22c5a4f5d67bcc92cd14c95d992 100644 --- a/library/ZendAfi/View/Helper/Album/OldLoans.php +++ b/library/ZendAfi/View/Helper/Album/OldLoans.php @@ -26,12 +26,12 @@ class ZendAfi_View_Helper_Album_OldLoans extends ZendAfi_View_Helper_Album_Loans } - protected function _getEmptyMessage() { - return $this->_('Le document n\'a pas encore été emprunté'); + protected function _getEmptyMessage() : string { + return $this->_('Le document n\'a pas encore été emprunté, ou les derniers prêts datent de plus de 4 mois.'); } - protected function _getLoans($item) { + protected function _getLoans($item) : Array { return Class_Loan_Pnb::findLastPastLoansForItem($item); } } \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/Notice/Dilicom.php b/library/ZendAfi/View/Helper/Notice/Dilicom.php index e2ee5434cef9545fd73cad1fb275ea37b8162248..2c545db6ef45911485051ec7b6090b287feea689 100644 --- a/library/ZendAfi/View/Helper/Notice/Dilicom.php +++ b/library/ZendAfi/View/Helper/Notice/Dilicom.php @@ -101,6 +101,7 @@ class ZendAfi_View_Helper_Notice_Dilicom extends ZendAfi_View_Helper_BaseHelper return $this->_withItemsDo( function($item) { $constraints = $item->getUsageConstraints(); + $usage_report = Class_Album_UsageReport::findFirstBy(['item_id' => $item->getId()]); return $this->_tag('h3', $constraints->getLoanOrderLineId()) . $this->_tag('div', $this->view->Album_UsageConstraints($constraints) @@ -113,6 +114,9 @@ class ZendAfi_View_Helper_Notice_Dilicom extends ZendAfi_View_Helper_BaseHelper $this->_tag('dt', $this->_('Prêts simultanés en cours')) . $this->_tag('dd', $item->getLoanCount()) . $this->_tag('dt', $this->_('Prêts simultanés autorisés')) . $this->_tag('dd', $item->getLoanAllowedNumberOfUsers()) + . + $this->_tag('dt', $this->_('Prêts historiques totaux')) . $this->_tag('dd', $usage_report->getLoanQuantityOrLocalLoanCount()) + . $this->_tag('dt', $this->_('Prêts simultanés restants')) . $this->_tag('dd', $item->numberOfSimultaneousLoansRemaning()) . diff --git a/tests/scenarios/PnbDilicom/PnbDilicomAdminTest.php b/tests/scenarios/PnbDilicom/PnbDilicomAdminTest.php index 78bc7932794583da14c8cda7325c84ecc66d606e..b32d4fbf182421eba85a3f39c2856789f3481de3 100644 --- a/tests/scenarios/PnbDilicom/PnbDilicomAdminTest.php +++ b/tests/scenarios/PnbDilicom/PnbDilicomAdminTest.php @@ -34,33 +34,33 @@ abstract class PnbDilicomAdminTestCase extends Admin_AbstractControllerTestCase RessourcesNumeriquesFixtures::activateDilicom(); - $this->fixture('Class_Album', + $this->fixture(Class_Album::class, ['id' => 23, 'id_origine' => 'Dilicom-36636', 'titre' => 'Being human being', 'type_doc_id' => Class_TypeDoc::DILICOM, ]); - $this->fixture('Class_Album_Item', + $this->fixture(Class_Album_Item::class, ['id' => 1, 'quantity' => '10', 'loan_count' => '2', 'album_id' => 23, 'usage_constraints' => [ - $this->fixture('Class_Album_UsageConstraint', + $this->fixture(Class_Album_UsageConstraint::class, ['id' => 1, 'usage_type' => Class_Album_UsageConstraint::LOAN_CONSTRAINT, 'serialized_datas' => json_encode([Class_Album_UsageConstraint::DURATION => 45, Class_Album_UsageConstraint::QUANTITY => 30, Class_Album_UsageConstraint::MAX_NB_OF_USERS => 15])]), - $this->fixture('Class_Album_UsageConstraint', + $this->fixture(Class_Album_UsageConstraint::class, ['id' => 2, 'usage_type' => Class_Album_UsageConstraint::DEVICE_SHARE_CONSTRAINT, 'serialized_datas' => json_encode([Class_Album_UsageConstraint::QUANTITY => 6])]), - $this->fixture('Class_Album_UsageConstraint', + $this->fixture(Class_Album_UsageConstraint::class, ['id' => 3, 'usage_type' => Class_Album_UsageConstraint::AVAILABILITY_CONSTRAINT, 'serialized_datas' => json_encode([Class_Album_UsageConstraint::DURATION => 2345, @@ -69,7 +69,27 @@ abstract class PnbDilicomAdminTestCase extends Admin_AbstractControllerTestCase ] ]); - $this->fixture('Class_Loan_Pnb', + $this->fixture(Class_Users::class, + ['id' => 4077, + 'login' => 'ppersonne', + 'idabon'=> '000005', + 'nom' => 'Personne', + 'prenom' => 'Paul', + 'password' => 'secret' + ]); + + + $this->fixture(Class_Users::class, + ['id' => 4078, + 'login' => 'drivers', + 'idabon'=> '000006', + 'nom' => 'Rivers', + 'prenom' => 'Dick', + 'password' => 'secret' + ]); + + + $this->fixture(Class_Loan_Pnb::class, ['id' => 1, 'record_origin_id' => 'Dilicom-36636', 'subscriber_id' => '000005', @@ -79,7 +99,7 @@ abstract class PnbDilicomAdminTestCase extends Admin_AbstractControllerTestCase 'loan_link' => 'https://pnb-dilicom.centprod.com/v2//XXXXXXXX.do', 'order_line_id' => '12385',]); - $this->fixture('Class_Loan_Pnb', + $this->fixture(Class_Loan_Pnb::class, ['id' => 2, 'record_origin_id' => 'Dilicom-36636', 'subscriber_id' => '000006', @@ -90,21 +110,21 @@ abstract class PnbDilicomAdminTestCase extends Admin_AbstractControllerTestCase 'order_line_id' => '12385',]); - $this->fixture('Class_Album_Item', + $this->fixture(Class_Album_Item::class, ['id' => 2, 'quantity' => '20', 'loan_count' => '5', 'album_id' => 23, 'usage_constraints' => [ - $this->fixture('Class_Album_UsageConstraint', + $this->fixture(Class_Album_UsageConstraint::class, ['id' => 4, 'usage_type' => Class_Album_UsageConstraint::LOAN_CONSTRAINT, 'serialized_datas' => json_encode([Class_Album_UsageConstraint::DURATION => 20, Class_Album_UsageConstraint::QUANTITY => 20, Class_Album_UsageConstraint::MAX_NB_OF_USERS => 15])]), - $this->fixture('Class_Album_UsageConstraint', + $this->fixture(Class_Album_UsageConstraint::class, ['id' => 5, 'usage_type' => Class_Album_UsageConstraint::AVAILABILITY_CONSTRAINT, 'serialized_datas' => json_encode([Class_Album_UsageConstraint::DURATION => 20000, @@ -114,27 +134,27 @@ abstract class PnbDilicomAdminTestCase extends Admin_AbstractControllerTestCase ]); - $this->fixture('Class_CodifGenre', + $this->fixture(Class_CodifGenre::class, ['id' => 23, 'libelle' => 'Heavy Metal']); - $this->fixture('Class_CodifGenre', + $this->fixture(Class_CodifGenre::class, ['id' => 24, 'libelle' => 'Jazz']); - $this->fixture('Class_CodifSection', + $this->fixture(Class_CodifSection::class, ['id' => 33, 'libelle' => 'Espace métal']); - $this->fixture('Class_CodifSection', + $this->fixture(Class_CodifSection::class, ['id' => 34, 'libelle' => 'Espace jazz']); - $fondu = $this->fixture('Class_AlbumCategorie', + $fondu = $this->fixture(Class_AlbumCategorie::class, ['id' => 1301, 'libelle' => 'Fondu']); - $this->fixture('Class_Album', + $this->fixture(Class_Album::class, ['id' => 9999, 'id_origine' => 'Dilicom-3663608260879', 'titre' => 'Hell is from here to eternity', @@ -148,26 +168,26 @@ abstract class PnbDilicomAdminTestCase extends Admin_AbstractControllerTestCase ->setAnnee(1992) ; - $this->fixture('Class_Album_Item', + $this->fixture(Class_Album_Item::class, ['id' => 9, 'quantity' => 990000, 'loan_count' => 3, 'album_id' => 9999, 'usage_constraints' => [ - $this->fixture('Class_Album_UsageConstraint', + $this->fixture(Class_Album_UsageConstraint::class, ['id' => 6, 'usage_type' => Class_Album_UsageConstraint::LOAN_CONSTRAINT, 'serialized_datas' => json_encode([Class_Album_UsageConstraint::DURATION => 359, Class_Album_UsageConstraint::QUANTITY => 999999, Class_Album_UsageConstraint::MAX_NB_OF_USERS => 1])]), - $this->fixture('Class_Album_UsageConstraint', + $this->fixture(Class_Album_UsageConstraint::class, ['id' => 7, 'usage_type' => Class_Album_UsageConstraint::DEVICE_SHARE_CONSTRAINT, 'serialized_datas' => json_encode([Class_Album_UsageConstraint::QUANTITY => 6])]), - $this->fixture('Class_Album_UsageConstraint', + $this->fixture(Class_Album_UsageConstraint::class, ['id' => 8, 'usage_type' => Class_Album_UsageConstraint::AVAILABILITY_CONSTRAINT, 'serialized_datas' => json_encode([Class_Album_UsageConstraint::DURATION => 999999, @@ -176,7 +196,7 @@ abstract class PnbDilicomAdminTestCase extends Admin_AbstractControllerTestCase ] ]); - $this->fixture('Class_Loan_Pnb', + $this->fixture(Class_Loan_Pnb::class, ['id' => 3, 'record_origin_id' => 'Dilicom-3663608260879', 'subscriber_id' => '000005', @@ -186,7 +206,7 @@ abstract class PnbDilicomAdminTestCase extends Admin_AbstractControllerTestCase 'loan_link' => 'https://pnb-dilicom.centprod.com/v2//XXXXXXXX.do', 'order_line_id' => '584837a045ce56ef0a072a8b',]); - $this->fixture('Class_Loan_Pnb', + $this->fixture(Class_Loan_Pnb::class, ['id' => 4, 'record_origin_id' => 'Dilicom-3663608260879', 'subscriber_id' => '000006', @@ -204,7 +224,7 @@ abstract class PnbDilicomAdminTestCase extends Admin_AbstractControllerTestCase foreach(range(1, 6) as $i) - $this->fixture('Class_Hold_Pnb', + $this->fixture(Class_Hold_Pnb::class, ['id' => $i, 'record_origin_id' => 'Dilicom-3663608260879', 'user_id' => $i, @@ -830,7 +850,7 @@ class PnbDilicomAdminAlbumControllerExportLoansCsvTest extends PnbDilicomAdminTe public function setUp() { parent::setUp(); - $this->fixture('Class_Users', + $this->fixture(Class_Users::class, ['id' => 7, 'nom' => 'boum', 'login'=>'boum', @@ -838,11 +858,21 @@ class PnbDilicomAdminAlbumControllerExportLoansCsvTest extends PnbDilicomAdminTe 'id_site' => 1, 'idabon' => '9878']); - $this->fixture('Class_Bib', ['id' => 1, - 'libelle' => 'SomewhereInCode', - 'gln' => '333']); - $this->fixture('Class_Loan_Pnb', + $this->fixture(Class_Users::class, + ['id' => 12321, + 'nom' => 'Riri', + 'login'=>'Duck', + 'password'=>'secret', + 'id_site' => 1, + 'idabon' => '1041']); + + $this->fixture(Class_Bib::class, + ['id' => 1, + 'libelle' => 'SomewhereInCode', + 'gln' => '333']); + + $this->fixture(Class_Loan_Pnb::class, ['id' => 5, 'record_origin_id' => 'Dilicom-3663608260879', 'subscriber_id' => 9879, @@ -852,10 +882,10 @@ class PnbDilicomAdminAlbumControllerExportLoansCsvTest extends PnbDilicomAdminTe 'loan_link' => 'https://pnb-dilicom.centprod.com/v2//XXXXXXXX.do', 'order_line_id' => '82377a045ce56ef0a072a8b']); - $this->fixture('Class_Loan_Pnb', + $this->fixture(Class_Loan_Pnb::class, ['id' => 6, 'record_origin_id' => 'Dilicom-3663608260879', - 'subscriber_id' => 9878, + 'subscriber_id' => 1041, 'user_id' => 12321, 'expected_return_date' => '2020-02-20 13:57:33', 'loan_date' => '2020-02-06 13:57:33', @@ -935,13 +965,13 @@ class PnbDilicomAdminAlbumControllerExportLoansCsvTest extends PnbDilicomAdminTe $this->dispatch('admin/pnb/export-loans-csv/' . $url); - $this->assertEquals('Date;Retour;Titre;"Date de commande";Auteur;Éditeur;Collection;Année;Genre;Section;Catégorie;Bibliothèque -16/12/2016;20/01/2017;"Being human being";30/03/2015;;;;;;;"Albums non classés"; -16/12/2016;20/01/2017;"Hell is from here to eternity";30/03/2015;"Iron Maiden";EMI;"Temple Of Rock";1992;"Heavy Metal";"Espace métal";Fondu; -13/11/2017;13/12/2017;"Being human being";30/03/2015;;;;;;;"Albums non classés"; -13/11/2017;13/12/2017;"Hell is from here to eternity";30/03/2015;"Iron Maiden";EMI;"Temple Of Rock";1992;"Heavy Metal";"Espace métal";Fondu; -06/01/2020;20/01/2020;"Hell is from here to eternity";;"Iron Maiden";EMI;"Temple Of Rock";1992;"Heavy Metal";"Espace métal";Fondu;SomewhereInCode -06/02/2020;20/02/2020;"Hell is from here to eternity";;"Iron Maiden";EMI;"Temple Of Rock";1992;"Heavy Metal";"Espace métal";Fondu;SomewhereInCode + $this->assertEquals('Date;Retour;Titre;"Date de commande";Auteur;Éditeur;Collection;Année;Genre;Section;Catégorie;Bibliothèque;"Login Emprunteur";"Carte Emprunteur";orderid +16/12/2016;20/01/2017;"Being human being";30/03/2015;;;;;;;"Albums non classés";;ppersonne;000005;12385 +16/12/2016;20/01/2017;"Hell is from here to eternity";30/03/2015;"Iron Maiden";EMI;"Temple Of Rock";1992;"Heavy Metal";"Espace métal";Fondu;;ppersonne;000005;584837a045ce56ef0a072a8b +13/11/2017;13/12/2017;"Being human being";30/03/2015;;;;;;;"Albums non classés";;drivers;000006;12385 +13/11/2017;13/12/2017;"Hell is from here to eternity";30/03/2015;"Iron Maiden";EMI;"Temple Of Rock";1992;"Heavy Metal";"Espace métal";Fondu;;drivers;000006;584837a045ce56ef0a072a8b +06/01/2020;20/01/2020;"Hell is from here to eternity";;"Iron Maiden";EMI;"Temple Of Rock";1992;"Heavy Metal";"Espace métal";Fondu;SomewhereInCode;boum;9878;82377a045ce56ef0a072a8b +06/02/2020;20/02/2020;"Hell is from here to eternity";;"Iron Maiden";EMI;"Temple Of Rock";1992;"Heavy Metal";"Espace métal";Fondu;SomewhereInCode;Duck;1041;82377a045ce56ef0a072a8b ', $this->_response->getBody()); } diff --git a/tests/scenarios/PnbDilicom/PnbDilicomTest.php b/tests/scenarios/PnbDilicom/PnbDilicomTest.php index 2e818ad2a4228a82f18bed7063149ace5efaae07..fbdb9a7c45560be39210ba1ca0dd3daf1ca268e7 100644 --- a/tests/scenarios/PnbDilicom/PnbDilicomTest.php +++ b/tests/scenarios/PnbDilicom/PnbDilicomTest.php @@ -965,7 +965,12 @@ class PnbDilicomRechercheControllerViewnoticeWithInspectorGadgetTest extends Adm $book->assertSave(); $book->index(); - $this->fixture('Class_Hold_Pnb', + $this->fixture(Class_Album_UsageReport::class, + [ 'id'=> 46, + 'item_id' => 1, + 'loan_quantity' => 4]); + + $this->fixture(Class_Hold_Pnb::class, ['id' => 1, 'user_id' => 6, 'record_origin_id' => $book->getIdOrigine(), @@ -1564,3 +1569,214 @@ class PnbDilicomOffersValidityUpdateFromXmlTest extends ModelTestCase { $this->assertEquals('2030-10-14T14:46:15+0200',$items[0]->getUsageConstraints()->getAvailabilityEndDate()); } } + + + + +abstract class PnbDilicomLoansTestCase extends PnbDilicomHoldsTestCase { + protected $_html; + + public function setUp(){ + parent::setUp(); + $this + ->_setupLoans(); + } + + public function tearDown(){ + Class_Loan_Pnb::setTimeSource(null); + parent::tearDown(); + } + + protected function _setupLoans() { + $timesource = new TimeSourceForTest('2022-06-10 10:23:10'); + Class_Loan_Pnb::setTimeSource($timesource); + $http = $this->mock() + ->whenCalled('open_url') + ->answers(''); + + Class_WebService_BibNumerique_Dilicom_Hub::setDefaultHttpClient($http); + + $this->fixture(Class_Loan_Pnb::class, + ['id' => 8, + 'user_id' => 6, + 'subscriber_id' => '', + 'record_origin_id' => $this->book->getIdOrigine(), + 'order_line_id' => 'x321', + 'loan_date' => '2022-03-01 20:10:00', + 'expected_return_date' => '2022-04-01 20:10:00']); + + $this->fixture(Class_Loan_Pnb::class, + ['id' => 9, + 'user_id' => 7, + 'subscriber_id' => '', + 'order_line_id' => 'x321', + 'record_origin_id' => $this->book->getIdOrigine(), + 'loan_date' => '2022-06-02 20:10:00', + 'expected_return_date' => '2022-06-24 20:10:00']); + + $this->fixture(Class_Loan_Pnb::class, + ['id' => 10, + 'user_id' => '', + 'subscriber_id' => 129, + 'order_line_id' => 'x321', + 'record_origin_id' => $this->book->getIdOrigine(), + 'loan_date' => '2022-06-01 20:10:00', + 'expected_return_date' => '2022-06-21 20:10:00']); + + $this->fixture(Class_Loan_Pnb::class, + ['id' => 11, + 'user_id' => 8, + 'subscriber_id' => '', + 'order_line_id' => 'x321', + 'record_origin_id' => $this->book->getIdOrigine(), + 'loan_date' => '2021-06-03 20:10:00', + 'expected_return_date' => '2021-08-03 20:10:00']); + + + $this->fixture(Class_Loan_Pnb::class, + ['id' => 12, + 'user_id' => 666, + 'subscriber_id' => '', + 'order_line_id' => 'x321', + 'record_origin_id' => $this->book->getIdOrigine(), + 'loan_date' => '2021-06-06 20:10:00', + 'expected_return_date' => '2021-06-26 20:10:00']); + + return $this; + } + + + public function getElements(){ + return [ + ['h3','thelma'], + ['td','2022-03-01 20:10:00'], + ['td','2022-04-01 20:10:00'], + ['h3','darryl'], + ['td','2021-06-03 20:10:00'], + ['td','2021-08-03 20:10:00'], + ['h3','Inconnu'], + ['td','2021-06-06 20:10:00'], + ['td','2021-06-26 20:10:00'], + + ]; + } + +} + + + + +class PnbDilicomLoansPageTest extends PnbDilicomLoansTestCase{ + + public function setUp() { + parent::setUp(); + + $helper = (new ZendAfi_View_Helper_Album_Loans(Class_Album_Item::find(1))) + ->setView(new ZendAfi_Controller_Action_Helper_View()); + $this->_html = $helper->Album_Loans(Class_Album_Item::find(1)); + } + + + /** @test */ + public function loansTabShould5LoansEntries() { + (new Storm_Test_XPath()) + ->assertXPathCount($this->_html, + '//h3', + 5); + } + + + /** @test + @dataProvider getElements + */ + public function loansTabShouldDisplayLoans($tag, $value) { + (new Storm_Test_XPath()) + ->assertXPathContentContains($this->_html, + '//'.$tag, + $value); + } +} + + + + + +class PnbDilicomOldLoansPageTest extends PnbDilicomLoansTestCase{ + public function setUp() { + parent::setUp(); + + $helper = (new ZendAfi_View_Helper_Album_OldLoans(Class_Album_Item::find(1))) + ->setView(new ZendAfi_Controller_Action_Helper_View()); + + $this->_html = $helper->Album_OldLoans(Class_Album_Item::find(1)); + + } + + + /** @test */ + public function oldLoansTabShould5LoansEntries() { + (new Storm_Test_XPath()) + ->assertXPathCount($this->_html, + '//h3', + 5); + } + + + /** @test + @dataProvider getElements + */ + public function oldLoansTabShouldDisplayLoans($tag, $value) { + (new Storm_Test_XPath()) + ->assertXPathContentContains($this->_html, + '//'.$tag, + $value); + + } +} + + + + +class PnbDilicomOldLoansQueryPageTest extends PnbDilicomLoansTestCase{ + public function setUp() { + parent::setUp(); + $this->_wrapper = $this->onLoaderOfModel(Class_Loan_Pnb::class); + + $helper = (new ZendAfi_View_Helper_Album_OldLoans(Class_Album_Item::find(1))) + ->setView(new ZendAfi_Controller_Action_Helper_View()); + + $this->_html = $helper->Album_OldLoans(Class_Album_Item::find(1)); + } + + + /** @test */ + public function oldLoansTabShouldCallFindAllByWithExpectedParams() { + $this->assertEquals([['order_line_id' => 'x321', + 'order' => 'expected_return_date desc', + 'limit' => 5, + 'where' => 'expected_return_date <= "2022-06-10 10:23:10" and expected_return_date >= "2022-02-08"']],$this->_wrapper->getAttributesForLastCallOn('findAllBy')); + } +} + + + + +class PnbDilicomLoansQueryPageTest extends PnbDilicomLoansTestCase{ + public function setUp() { + parent::setUp(); + $this->_wrapper = $this->onLoaderOfModel(Class_Loan_Pnb::class); + + $helper = (new ZendAfi_View_Helper_Album_Loans(Class_Album_Item::find(1))) + ->setView(new ZendAfi_Controller_Action_Helper_View()); + + $this->_html = $helper->Album_Loans(Class_Album_Item::find(1)); + } + + + /** @test */ + public function loansTabShouldCallExpectedFindAllBy() { + $this->assertEquals([['order_line_id' => 'x321', + 'where' => 'expected_return_date > "2022-06-10 10:23:10"']], + $this->_wrapper->getAttributesForLastCallOn('findAllBy')); + } +}