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

api/user/loans answers ids and thumbnails

parent d64d4d49
Branches
Tags
2 merge requests!2660Master,!2654Patrons ws for mybibapp
Pipeline #4147 failed with stage
in 32 minutes and 28 seconds
......@@ -30,13 +30,22 @@ class ZendAfi_View_Helper_Api_Loans extends Zend_View_Helper_Abstract {
public function loanToArray($loan) {
return [
'title' => $loan->getTitre(),
'author' => $loan->getAuteur(),
'date_due' => implode('-', array_reverse(explode('/', $loan->getDateRetour()))),
'loaned_by' => $loan->getUserFullName(),
'library' => $loan->getBibliotheque()
];
$datas = [
'id' => $loan->getId(),
'title' => $loan->getTitre(),
'author' => $loan->getAuteur(),
'date_due' => implode('-', array_reverse(explode('/', $loan->getDateRetour()))),
'loaned_by' => $loan->getUserFullName(),
'library' => $loan->getBibliotheque() ];
if (!$record = $loan->getNoticeOPAC())
return $datas;
$datas['record'] = ['id' => $record->getId()];
if ($record->hasVignette())
$datas['record']['thumbnail'] = $record->getUrlVignette();
return $datas;
}
}
?>
\ No newline at end of file
......@@ -46,9 +46,13 @@ abstract class Scenario_MobileApplication_UserAccountTestCase extends AbstractCo
$potter = new Class_WebService_SIGB_Emprunt('12', new Class_WebService_SIGB_Exemplaire(123));
$potter
->setDateRetour('01/01/1974')
->setAuteur('J.K.R')
->setBibliotheque('Annecy')
->getExemplaire()->setTitre('Potter');
->getExemplaire()
->setNoticeOPAC($this->fixture('Class_Notice',
['id' => 34,
'url_vignette' => 'http://img.com/potter.jpg',
'titre_principal' => 'Potter',
'auteur_principal' => 'J.K.R' ]));
$alice = new Class_WebService_SIGB_Emprunt('13', new Class_WebService_SIGB_Exemplaire(456));
$alice
......@@ -93,11 +97,14 @@ class Scenario_MobileApplication_UserAccountLoansWithTokenTest extends Scenario_
/** @test */
public function responseShouldContainsPotterLoan() {
$this->assertEquals(['title' => 'Potter',
$this->assertEquals(['id' => '345_12',
'title' => 'Potter',
'author' => 'J.K.R',
'date_due' => '1974-01-01',
'loaned_by' => 'puppy',
'library' => 'Annecy'
'library' => 'Annecy',
'record' => [ 'id' => '34',
'thumbnail' => 'http://img.com/potter.jpg' ]
],
$this->_json['loans'][0]);
}
......
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