diff --git a/VERSIONS_HOTLINE/83325 b/VERSIONS_HOTLINE/83325 new file mode 100644 index 0000000000000000000000000000000000000000..aa45024aa05a8f2986450bf0b16e2c6e88ef51d8 --- /dev/null +++ b/VERSIONS_HOTLINE/83325 @@ -0,0 +1 @@ + - ticket #83325 : PNB Dilicom : si un document a atteint la limit d'emprunts simultanés, n'interdit pas à un abonné qui a un emprunt en cours de le télécharger de nouveau \ No newline at end of file diff --git a/library/Class/WebService/BibNumerique/Dilicom/Hub.php b/library/Class/WebService/BibNumerique/Dilicom/Hub.php index 622ca35eb69941e22d934611625d0975dc878a0b..2efdfc65fd37cf39677452135d4de67a24161f68 100644 --- a/library/Class/WebService/BibNumerique/Dilicom/Hub.php +++ b/library/Class/WebService/BibNumerique/Dilicom/Hub.php @@ -176,14 +176,14 @@ class Class_WebService_BibNumerique_Dilicom_Hub extends Class_WebService_Abstrac public function isAlbumLoanableBy($album, $user) { - $loanable = $this->_isAlbumLoanable($album); - if ($error = $loanable->returnMessage) - return $loanable; - $currently_loaned_by_user = $this->_isAlbumCurrentlyLoanedByUser($album, $user); if (!$currently_loaned_by_user->returnMessage) return $currently_loaned_by_user; + $loanable = $this->_isAlbumLoanable($album); + if ($error = $loanable->returnMessage) + return $loanable; + return $this->_isAlbumLoanableByUser($album, $user); } diff --git a/tests/scenarios/PnbDilicom/PnbDilicomTest.php b/tests/scenarios/PnbDilicom/PnbDilicomTest.php index 53133e5baf5a051360486258b51f168c12b5c3be..3cd2f52aa99fcb829847ac83786bde61836a137d 100644 --- a/tests/scenarios/PnbDilicom/PnbDilicomTest.php +++ b/tests/scenarios/PnbDilicom/PnbDilicomTest.php @@ -1806,6 +1806,18 @@ class PnbDilicomViewHelperRenderAlbumPNBGetLoanStatusTest extends PnbDilicomView $this->logged_user->beAbonneSIGB()->assertSave(); ZendAfi_Auth::getInstance()->logUser($this->logged_user); + + + $this->other_user = $this->fixture('Class_Users', + ['id' => 7, + 'nom'=>'Boum', + 'login'=>'Baia', + 'password'=>'9876', + 'id_site' => 1, + 'idabon' => '9876', + 'user_groups' => [$group]]); + + $this->other_user->beAbonneSIGB()->assertSave(); } @@ -1844,13 +1856,13 @@ class PnbDilicomViewHelperRenderAlbumPNBGetLoanStatusTest extends PnbDilicomView /** @test */ - public function htmlShouldContainsNextAvailableLoanDate() { - Class_Album_UsageConstraint::find(1)->setMaxNumberOfUsers(0)->assertSave(); + public function withSimultaneousLoanLimitReachedHtmlShouldContainsNextAvailableLoanDate() { + Class_Album_UsageConstraint::find(1)->setMaxNumberOfUsers(1)->assertSave(); Class_AdminVar::set('DILICOM_PNB_LOAN_COUNT_LIMIT',0); $this->fixture('Class_Loan_Pnb', ['id' => 1, - 'user_id' => $this->logged_user->getId(), - 'record_origin_id' => 1, + 'user_id' => $this->other_user->getId(), + 'record_origin_id' => 'Dilicom-88817216', 'order_line_id' => 'x321', 'expected_return_date' => '2022-06-01 20:10:00']); @@ -1862,6 +1874,26 @@ class PnbDilicomViewHelperRenderAlbumPNBGetLoanStatusTest extends PnbDilicomView } + /** @test */ + public function withSimultaneousLoanLimitReachedButCurrentlyLoanedByCurrentUserHtmlShouldContainsButtonToLoadAgain() { + Class_Album_UsageConstraint::find(1)->setMaxNumberOfUsers(0)->assertSave(); + Class_AdminVar::set('DILICOM_PNB_LOAN_COUNT_LIMIT',0); + $this->fixture('Class_Loan_Pnb', + ['id' => 1, + 'user_id' => $this->logged_user->getId(), + 'record_origin_id' => 'Dilicom-88817216', + 'order_line_id' => 'x321', + 'expected_return_date' => '2025-06-01 20:10:00', + 'loan_link' => 'https://pnb-dilicom.centprod.com/v3//link/xxx.do']); + + $this->_html = $this->_helper->renderAlbum($this->book); + + $this->assertXPath($this->_html, + '//a[contains(@href, "/bib-numerique/loan-book-ajax/id/3")]', + $this->_html); + } + + /** @test */ public function onUnknownReturnDateHtmlShouldNotContainsNextAvailableLoanDate() { Class_Album_UsageConstraint::find(1)->setMaxNumberOfUsers(0)->assertSave();