Commit eddb72ad authored by Patrick Barroca's avatar Patrick Barroca 😠

Merge branch 'hotline#83325_emprunt_livre_numerique_expire_le_105' into 'hotline'

hotline #83325 PNB Dilicom : fix download for an user that currently loan it and…

See merge request afi/opacce!3108
parents 8f5888f5 5d643a9a
- 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
......@@ -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);
}
......
......@@ -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();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment