Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
opacce
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
7
Merge Requests
7
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
afi
opacce
Commits
80ba0a9c
Commit
80ba0a9c
authored
Mar 26, 2020
by
Patrick Barroca
🐧
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hotline #108377 : fix Dilicom quota of guest users
parent
456d1f86
Pipeline
#9743
passed with stage
in 43 minutes and 10 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
124 additions
and
7 deletions
+124
-7
108377
VERSIONS_HOTLINE/108377
+1
-0
Pnb.php
library/Class/Loan/Pnb.php
+12
-6
PnbDilicomTest.php
tests/scenarios/PnbDilicom/PnbDilicomTest.php
+111
-1
No files found.
VERSIONS_HOTLINE/108377
0 → 100644
View file @
80ba0a9c
- ticket #108377 : Ressources numériques : Correction du calcul du quota de prêt pour les invités
\ No newline at end of file
library/Class/Loan/Pnb.php
View file @
80ba0a9c
<?php
/**
* Copyright (c) 2012-20
14
, Agence Française Informatique (AFI). All rights reserved.
* Copyright (c) 2012-20
20
, 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
...
...
@@ -21,11 +21,7 @@
class
Class_Loan_PnbLoader
extends
Storm_Model_Loader
{
public
function
findAllOngoingOfUser
(
$user
)
{
$loans
=
array_unique
(
array_merge
(
$this
->
findAllOngoingBy
([
'subscriber_id'
=>
$user
->
getIdabon
()]),
$this
->
findAllOngoingBy
([
'user_id'
=>
$user
->
getId
()])));
$loans
=
$this
->
_ongoingOf
(
$user
);
(
new
Class_WebService_BibNumerique_Dilicom_Hub
())
->
updateLoansReturnDate
(
$loans
);
...
...
@@ -37,6 +33,16 @@ class Class_Loan_PnbLoader extends Storm_Model_Loader {
}
protected
function
_ongoingOf
(
$user
)
{
$by_user_id
=
$this
->
findAllOngoingBy
([
'user_id'
=>
$user
->
getId
()]);
if
(
!
$user
->
isAbonne
())
return
$by_user_id
;
return
array_unique
(
array_merge
(
$this
->
findAllOngoingBy
([
'subscriber_id'
=>
$user
->
getIdabon
()]),
$by_user_id
));
}
public
function
findAllOngoingOfItem
(
$item
)
{
$loans
=
$this
->
findAllOngoingBy
([
'order_line_id'
=>
$item
->
getOrderLineId
()]);
(
new
Class_WebService_BibNumerique_Dilicom_Hub
())
->
updateLoansReturnDate
(
$loans
);
...
...
tests/scenarios/PnbDilicom/PnbDilicomTest.php
View file @
80ba0a9c
...
...
@@ -2645,7 +2645,8 @@ class PnbDilicomBibNumeriqueControllerConsultBookWithErrorsActionTest extends Pn
class
PnbDilicomBibNumeriqueControllerLoanBookActionTest
extends
PnbDilicomBibNumeriqueControllerLoanBookActionTestCase
{
class
PnbDilicomBibNumeriqueControllerLoanBookActionTest
extends
PnbDilicomBibNumeriqueControllerLoanBookActionTestCase
{
public
function
setUp
()
{
parent
::
setUp
();
...
...
@@ -2781,6 +2782,115 @@ class PnbDilicomBibNumeriqueControllerLoanBookActionTwiceWithSameUserTest extend
/** @see http://forge.afi-sa.fr/issues/108377 */
abstract
class
PnbDilicomBibNumeriqueControllerLoanBookActionGuestTestCase
extends
PnbDilicomBibNumeriqueControllerTestCase
{
public
function
setUp
()
{
parent
::
setUp
();
Class_AdminVar
::
set
(
'DILICOM_PNB_MAX_LOAN_PER_USER'
,
3
);
$user
=
$this
->
fixture
(
'Class_Users'
,
[
'id'
=>
88
,
'login'
=>
'guest'
,
'password'
=>
'roxor'
,
'id_site'
=>
1
,
'user_groups'
=>
[
Class_UserGroup
::
find
(
20
)],
'role'
=>
ZendAfi_Acl_AdminControllerRoles
::
INVITE
,
]);
ZendAfi_Auth
::
getInstance
()
->
logUser
(
$user
);
}
}
class
PnbDilicomBibNumeriqueControllerLoanBookActionGuestWithOtherGuestsLoansTest
extends
PnbDilicomBibNumeriqueControllerLoanBookActionGuestTestCase
{
public
function
setUp
()
{
parent
::
setUp
();
foreach
(
range
(
1
,
6
)
as
$i
)
$this
->
fixture
(
'Class_Loan_Pnb'
,
[
'id'
=>
10000
+
$i
,
'user_id'
=>
10000
+
$i
,
'subscriber_id'
=>
''
,
'record_origin_id'
=>
''
,
'expected_return_date'
=>
'2022-06-01'
]);
$this
->
_http
->
whenCalled
(
'open_url'
)
->
with
(
'https://pnb-test.centprod.com/v3/pnb-numerique/json/getEndedLoans?login=afi-bib&password=secretPassword&glnContractor=123456789&loanId%5B0%5D=10001&loanId%5B1%5D=10002&loanId%5B2%5D=10003&loanId%5B3%5D=10004&loanId%5B4%5D=10005&loanId%5B5%5D=10006'
,
[
'auth'
=>
[
'user'
=>
'afi-bib'
,
'password'
=>
'secretPassword'
]])
->
answers
(
DilicomFixtures
::
getEndedLoansResponse
())
->
whenCalled
(
'open_url'
)
->
with
(
'https://pnb-test.centprod.com/v3/pnb-numerique/json/getLoanStatus?login=afi-bib&password=secretPassword&glnContractor=123456789&orderLineId%5B0%5D=x321&returnEndedLoan=0'
,
[
'auth'
=>
[
'user'
=>
'afi-bib'
,
'password'
=>
'secretPassword'
]])
->
answers
(
DilicomFixtures
::
getLoanStatusResponse
())
->
whenCalled
(
'open_url'
)
->
with
(
'https://pnb-test.centprod.com/v3/pnb-numerique/json/loanBook?login=afi-bib&password=secretPassword&glnContractor=123456789&glnLoaner=2345889&UserInfo.year=1930&UserInfo.gender=H&DRMinfo.readerPass=MTA%3D&DRMinfo.readerHint=Votre+login+est+%22drm%22+et+votre+mot+de+passe+est+%220000%22&DRMinfo.readerId=drm&orderLineId=x321&loanId=10007&ean13=435465&accessMedium=DOWNLOAD&localization=EX_SITU&loanEndDate=2014-08-10T14%3A14%3A14%2B0200'
,
[
'auth'
=>
[
'user'
=>
'afi-bib'
,
'password'
=>
'secretPassword'
]])
->
answers
(
DilicomFixtures
::
loanBookResponse
())
;
$this
->
dispatch
(
'/bib-numerique/loan-book/id/3'
);
}
/** @test */
public
function
shouldBeAbleToLoan
()
{
$this
->
assertNotNull
(
Class_Loan_Pnb
::
find
(
10007
));
}
}
class
PnbDilicomBibNumeriqueControllerLoanBookActionGuestWithExceededLoansTest
extends
PnbDilicomBibNumeriqueControllerLoanBookActionGuestTestCase
{
public
function
setUp
()
{
parent
::
setUp
();
foreach
(
range
(
1
,
6
)
as
$i
)
$this
->
fixture
(
'Class_Loan_Pnb'
,
[
'id'
=>
10000
+
$i
,
'user_id'
=>
Class_Users
::
getIdentity
()
->
getId
(),
'subscriber_id'
=>
''
,
'record_origin_id'
=>
''
,
'expected_return_date'
=>
'2022-06-01'
]);
$this
->
_http
->
whenCalled
(
'open_url'
)
->
with
(
'https://pnb-test.centprod.com/v3/pnb-numerique/json/getEndedLoans?login=afi-bib&password=secretPassword&glnContractor=123456789&loanId%5B0%5D=10001&loanId%5B1%5D=10002&loanId%5B2%5D=10003&loanId%5B3%5D=10004&loanId%5B4%5D=10005&loanId%5B5%5D=10006'
,
[
'auth'
=>
[
'user'
=>
'afi-bib'
,
'password'
=>
'secretPassword'
]])
->
answers
(
DilicomFixtures
::
getEndedLoansResponse
())
;
$this
->
dispatch
(
'/bib-numerique/loan-book/id/3'
);
}
/** @test */
public
function
shouldNotBeAbleToLoan
()
{
$this
->
assertNull
(
Class_Loan_Pnb
::
find
(
10007
));
}
}
abstract
class
PnbDilicomBibNumeriqueControllerSecondUserTestCase
extends
PnbDilicomBibNumeriqueControllerTestCase
{
public
function
setUp
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment