Skip to content
Snippets Groups Projects
Commit 0cf39d1c authored by Ghislain Loas's avatar Ghislain Loas
Browse files

dev #30973 Update Dilicom item status after loan + add update all script

parent 7deb15e3
Branches
Tags
5 merge requests!1553Master,!1502Master,!1501Stable,!1328Dev#30973 pnb backoffice table,!1294Dev#30973 pnb backoffice table
......@@ -162,11 +162,13 @@ class Class_WebService_BibNumerique_Dilicom_Hub extends Class_WebService_Abstrac
$content = json_decode($response);
$loan->setLoanLink($content->link->url)->save();
if($content->returnMessage)
if ($content->returnMessage) {
$loan->delete();
return $content;
}
$loan->setLoanLink($content->link->url)->save();
$this->updateStatus($album);
return $content;
}
......
<?php
error_reporting(E_ERROR | E_PARSE);
require(__DIR__.'/../console.php');
$hub = new Class_WebService_BibNumerique_Dilicom_Hub();
$items = Class_Album_Item::findAll();
foreach($items as $item) {
$content = $hub->updateStatus($item->getAlbum());
echo 'updated [' . $content->returnStatus . '] ' .$item->getAlbum()->getTitre()."\n";
}
?>
\ No newline at end of file
......@@ -322,10 +322,24 @@ class BibNumeriqueControllerDilicomLoanBookActionTest extends BibNumeriqueContol
Class_AdminVar::set('DILICOM_PNB_LOAN_COUNT_LIMIT', 0);
$update_status_url = 'https://pnb-test.centprod.com/v2/pnb-numerique/json/getLoanStatus?glnContractor=123456789&orderLineId[0]=x321';
$this->_http
->whenCalled('open_url')
->with('https://pnb-test.centprod.com/v2/pnb-numerique/json/loanBook?glnContractor=123456789&orderLineId=x321&accessMedium=DOWNLOAD&glnColl=afi-bib&loanerColl=2345889&localization=EX_SITU&loanEndDate=2014-08-10T14%3A14%3A14%2B0200&ean13=435465&loanId=1')
->answers(DilicomFixtures::loanBookResponse())
->whenCalled('open_url')
->with($update_status_url)
->willDo(function() use ($update_status_url)
{
$this->_http
->whenCalled('open_url')
->with($update_status_url)
->answers(DilicomFixtures::getLoanStatusAfterLoanResponse());
return DilicomFixtures::getLoanStatusResponse();
})
->beStrict();
$this->dispatch('/bib-numerique/loan-book/id/3', true);
......@@ -348,6 +362,12 @@ class BibNumeriqueControllerDilicomLoanBookActionTest extends BibNumeriqueContol
public function loanUrlShouldHaveBeenSaved() {
$this->assertEquals('https://pnb-dilicom.centprod.com/v2//link/3025594195810/LOAN/WIKI001/9782021153057-NUMOIY0785CYO0IGCV83DE9DOAOC1Y1O.do', Class_Loan_Pnb::findFirstBy(['record_origin_id' => 'Dilicom-88817216'])->getLoanLink());
}
/** @test */
public function itemQuantityShouldEqualsTwentySeven() {
$this->assertEquals(27, $this->book->getItems()[0]->getQuantity());
}
}
......
......@@ -97,6 +97,24 @@ class DilicomFixtures {
}
public static function getLoanStatusAfterLoanResponse() {
return '{
"date" : "2014-08-14T11:32:12.786+02:00",
"returnStatus" : "OK",
"returnMessage" : [ ],
"loanResponseLine" : [ {
"returnStatus" : "OK",
"orderLineId" : "537119f5975a1d3260801864",
"nta" : 23,
"nus1" : 4,
"nus2" : 30,
"beginDate" : "2014-05-12T20:59:03+02:00",
"endDate" : "2015-05-12T20:59:03+02:00"
} ]
}';
}
public static function getLoanStatusNoQuantityLeftResponse() {
return '{
"date" : "2014-08-14T11:32:12.786+02:00",
......
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