diff --git a/VERSIONS_HOTLINE/75730 b/VERSIONS_HOTLINE/75730 new file mode 100644 index 0000000000000000000000000000000000000000..d5e21016df5abc888d21ecebf3a4ff4da77e8595 --- /dev/null +++ b/VERSIONS_HOTLINE/75730 @@ -0,0 +1 @@ + - ticket #75730 : MyBibApp: correction de la récupération des prêts PNB. \ No newline at end of file diff --git a/application/modules/api/controllers/UserController.php b/application/modules/api/controllers/UserController.php index 7688562b97a07c4168fbdc4fc421386a10a68301..d6fa2551391c76eaec1f1b537df9c8bd4dc364b7 100644 --- a/application/modules/api/controllers/UserController.php +++ b/application/modules/api/controllers/UserController.php @@ -23,7 +23,8 @@ class Api_UserController extends ZendAfi_Controller_Action { public function preDispatch() { parent::preDispatch(); - $this->_authenticate(); + if (!Class_Users::hasIdentity()) + $this->_authenticate(); } diff --git a/library/Class/Loan/Pnb.php b/library/Class/Loan/Pnb.php index 18f62bbbd6b3c7609073f03ae5000d12e7c3410c..ceb8f5a60df45d1a88c6e7282d1b75a1328219da 100644 --- a/library/Class/Loan/Pnb.php +++ b/library/Class/Loan/Pnb.php @@ -104,6 +104,13 @@ class Class_Loan_Pnb extends Storm_Model_Abstract { } + public function getNoticeOPAC() { + return ($album = $this->getAlbum()) + ? $album->getNotice() + : null; + } + + public function setAlbum($album) { return $this->setRecordOriginId($album->getIdOrigine()); } @@ -144,6 +151,12 @@ class Class_Loan_Pnb extends Storm_Model_Abstract { } + public function getDateRetourISO8601() { + return substr($this->getDateRetour(), 0, 10); + } + + + public function isRenewable() { return false; } diff --git a/library/ZendAfi/View/Helper/Api/Holds.php b/library/ZendAfi/View/Helper/Api/Holds.php index ddafc3d948cd3f7122b1fbee0c5d5b1b9f8a2b43..792a609e48faf66d5935a51c0c1e11ef6e68fa88 100644 --- a/library/ZendAfi/View/Helper/Api/Holds.php +++ b/library/ZendAfi/View/Helper/Api/Holds.php @@ -32,7 +32,7 @@ class ZendAfi_View_Helper_Api_Holds extends Zend_View_Helper_Abstract { public function holdToArray($hold) { $datas = [ 'id' => $hold->getId(), - 'title' => $hold->getTitre(), + 'title' => strip_tags($loan->getTitre()), 'author' => $hold->getAuteur(), 'status' => $hold->getEtat(), 'held_by' => $hold->getUserFullName(), diff --git a/library/ZendAfi/View/Helper/Api/Loans.php b/library/ZendAfi/View/Helper/Api/Loans.php index d90cedf859b652827378b89951947af53c278167..566a189d7e96ec5a1e4c1f1e9970a735f52d696e 100644 --- a/library/ZendAfi/View/Helper/Api/Loans.php +++ b/library/ZendAfi/View/Helper/Api/Loans.php @@ -32,7 +32,7 @@ class ZendAfi_View_Helper_Api_Loans extends Zend_View_Helper_Abstract { public function loanToArray($loan) { $datas = [ 'id' => $loan->getId(), - 'title' => $loan->getTitre(), + 'title' => strip_tags($loan->getTitre()), 'author' => $loan->getAuteur(), 'date_due' => $loan->getDateRetourISO8601(), 'loaned_by' => $loan->getUserFullName(), diff --git a/tests/scenarios/MobileApplication/UserAccountTest.php b/tests/scenarios/MobileApplication/UserAccountTest.php index 935ef9517a35a14cc70864501c4d5ad257b0f684..e4b117057769aaeb01b262657535d49c8a8515b6 100644 --- a/tests/scenarios/MobileApplication/UserAccountTest.php +++ b/tests/scenarios/MobileApplication/UserAccountTest.php @@ -55,7 +55,7 @@ abstract class Scenario_MobileApplication_UserAccountTestCase extends AbstractCo ->setNoticeOPAC($this->fixture('Class_Notice', ['id' => 34, 'url_vignette' => 'http://img.com/potter.jpg', - 'titre_principal' => 'Potter', + 'titre_principal' => 'Harry Potter<br /> La chambre des secrets', 'auteur_principal' => 'J.K.R' ])); $alice = new Class_WebService_SIGB_Emprunt('13', new Class_WebService_SIGB_Exemplaire(456)); @@ -82,12 +82,32 @@ abstract class Scenario_MobileApplication_UserAccountTestCase extends AbstractCo ->reservationsAddAll([$afrodeezia])]) ->assertSave(); + + Class_WebService_BibNumerique_Dilicom_Hub::setDefaultHttpClient($this->mock() + ->whenCalled('open_url') + ->answers('')); + $this->fixture('Class_Loan_Pnb', + ['id' => 5, + 'subscriber_id' => $puppy->getIdabon(), + 'ongoing' => true, + 'expected_return_date' => '2022-05-02T18:14:14+02:00', + 'loan_date' => '2016-06-13T15:10:02+02:00', + 'album' => $this->fixture('Class_Album', + ['id' => 4, + 'notice_id' => 5, + 'id_origine' => 'Dilicom-88817216', + 'titre' => 'Pinocchio'])->addAuthor('Collodi') + ]); + + + ZendAfi_Auth::getInstance()->clearIdentity(); } public function tearDown() { unset($_SERVER['HTTPS']); + Class_WebService_BibNumerique_Dilicom_Hub::setDefaultHttpClient(null); parent::tearDown(); } } @@ -114,7 +134,7 @@ class Scenario_MobileApplication_UserAccountLoansWithTokenTest extends Scenario_ /** @test */ public function responseShouldContainsPotterLoan() { $this->assertEquals(['id' => '345_12', - 'title' => 'Potter', + 'title' => 'Harry Potter La chambre des secrets', 'author' => 'J.K.R', 'date_due' => '1974-01-01', 'loaned_by' => 'puppy', @@ -126,6 +146,19 @@ class Scenario_MobileApplication_UserAccountLoansWithTokenTest extends Scenario_ } + /** @test */ + public function responseShouldContainsPinocchioPnbLoan() { + $this->assertEquals(['id' => '345_5', + 'title' => 'Pinocchio', + 'author' => 'Collodi', + 'date_due' => '2022-05-02', + 'loaned_by' => 'puppy', + 'library' => '' + ], + $this->_json['loans'][2]); + } + + /** @test */ public function responseHeaderContentTypeShouldBeApplicationJson() { $this->assertArraySubset(['name' => 'Content-Type', @@ -288,6 +321,24 @@ class Scenario_MobileApplication_UserAccountLoansWithoutTokenTest extends Scenar ], $loans['loans'][0]); } + + + /** @test */ + public function withSessionOpenedShouldAnswerLoans() { + ZendAfi_Auth::getInstance()->logUser(Class_Users::find(345)); + $this->dispatch('/api/user/loans', + true, + ["Content-Type" => "application/json"]); + + $loans = json_decode($this->_response->getBody(), true); + $this->assertArraySubset(['title' => 'Potter', + 'author' => 'J.K.R', + 'date_due' => '1974-01-01', + 'loaned_by' => 'puppy', + 'library' => 'Annecy' + ], + $loans['loans'][0]); + } }