Skip to content
Snippets Groups Projects
Commit e4545235 authored by Laurent's avatar Laurent
Browse files

dev#30973 pnb_backoffice_table

fix loan pnb fetch for a user
parent 78007d64
Branches
Tags
4 merge requests!1553Master,!1502Master,!1501Stable,!1328Dev#30973 pnb backoffice table
......@@ -21,7 +21,10 @@
class Class_Loan_PnbLoader extends Storm_Model_Loader {
public function findAllOngoingOfUser($user) {
$loans = $this->findAllOngoingBy(['user_id' => $user->getId()]);
$loans =
array_merge(
$this->findAllOngoingBy(['subscriber_id' => $user->getIdabon()]),
$this->findAllOngoingBy(['user_id' => $user->getId()]));
(new Class_WebService_BibNumerique_Dilicom_Hub())
->updateLoansReturnDate($loans);
......
......@@ -43,6 +43,7 @@ abstract class AbstractAbonneControllerPretsTestCase extends AbstractControllerT
$this->florence = $this->fixture('Class_Users',
['id' => '123456',
'login' => 'flo',
'idabon' => 'x234',
'password' => 'flo']);
$this->zend_cache = Storm_Test_ObjectWrapper::mock();
......@@ -70,6 +71,9 @@ abstract class AbstractAbonneControllerPretsTestCase extends AbstractControllerT
->with('test-gln', 'test-gln-pass')
->answers(null)
->whenCalled('open_url')
->answers('')
->whenCalled('open_url')
->with('/v2/pnb-numerique/json/getEndedLoans?glnContractor=777&loanId[0]=5')
->answers(DilicomFixtures::getEndedLoansResponse())
......@@ -150,7 +154,7 @@ abstract class AbonneControllerPretsListThreePretsTestCase extends AbstractAbonn
$this->fixture('Class_Loan_Pnb',
['id' => 5,
'user_id' => $this->florence->getId(),
'subscriber_id' => $this->florence->getIdabon(),
'ongoing' => true,
'expected_return_date' => '2022-05-02T18:14:14+02:00',
'album' => $this->fixture('Class_Album',
......@@ -160,6 +164,20 @@ abstract class AbonneControllerPretsListThreePretsTestCase extends AbstractAbonn
'titre' => 'Pinocchio'])->addAuthor('Collodi')
]);
$this->fixture('Class_Loan_Pnb',
['id' => 6,
'user_id' => $this->florence->getId(),
'ongoing' => true,
'expected_return_date' => '2020-01-01T18:14:14+02:00',
'album' => $this->fixture('Class_Album',
['id' => 5,
'notice_id' => 6,
'id_origine' => 'Dilicom-88817217',
'titre' => 'Peter Pan'])
]);
$this->florence
->setFicheSigb(['type_comm' => 2, //OPSYS
'fiche' => $emprunteur,
......@@ -366,14 +384,23 @@ class AbonneControllerPretsListThreePretsTest extends AbonneControllerPretsListT
/** @test */
public function pinocchioPnbLoanReturnDateShouldBeAsExpected() {
public function pinocchioPnbLoanReturnDateShouldBe2022() {
$this->assertXPathContentContains('//tbody//td[@class="date_retour"]',
'2022-05-02T18:14:14+02:00');
}
/** @test */
public function peterPanPnbLoanReturnDateShouldBe2020() {
$this->assertXPathContentContains('//tbody//td[@class="date_retour"]',
'2020-01-01T18:14:14+02:00');
}
}
class AbonneControllerPretsListThreePretsPnbEarlyReturnTest extends AbonneControllerPretsListThreePretsTestCase {
public function setUp() {
parent::setUp();
......
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