Commit f2db33eb authored by Patrick Barroca's avatar Patrick Barroca 🐧

Merge branch…

Merge branch 'hotline#92518_pmb_afficher_les_messages_d_erreur_de_prolongation_de_pmb' into 'hotline'

hotline #92518 PMB : display renew loan error messages

See merge request afi/opacce!3134
parents 34216b14 cd891ae4
- ticket #92518 : SIGB PMB : correction de l'affichage des messages d'erreur de prolongation
\ No newline at end of file
...@@ -88,13 +88,13 @@ class Class_Webservice_SIGB_PMB_Service extends Class_WebService_SIGB_AbstractSe ...@@ -88,13 +88,13 @@ class Class_Webservice_SIGB_PMB_Service extends Class_WebService_SIGB_AbstractSe
$exemplaire->getIdOrigine()]); $exemplaire->getIdOrigine()]);
$result = (array) $this->_getJsonData($json, 'result'); $result = (array) $this->_getJsonData($json, 'result');
if(!$result) if (!$result)
return ['status' => false, 'erreur' => $this->_('Réservation impossible : le service de réservation PMB via webservice est indisponible')]; return $this->_error($this->_('Réservation impossible : le service de réservation PMB via webservice est indisponible'));
if(isset($result['error'])) if(isset($result['error']))
return ['status' => false, 'erreur' => $this->_('Réservation impossible : Vous avez déjà réservé cette exemplaire')]; return $this->_error($this->_('Réservation impossible : Vous avez déjà réservé cette exemplaire'));
return true; return $this->_success();
} }
...@@ -102,16 +102,23 @@ class Class_Webservice_SIGB_PMB_Service extends Class_WebService_SIGB_AbstractSe ...@@ -102,16 +102,23 @@ class Class_Webservice_SIGB_PMB_Service extends Class_WebService_SIGB_AbstractSe
$session_token = $this->openSessionForUser($user); $session_token = $this->openSessionForUser($user);
$json = $this->httpPost('pmbesOPACEmpr_delete_resa', [$session_token, $json = $this->httpPost('pmbesOPACEmpr_delete_resa', [$session_token,
$reservation_id]); $reservation_id]);
return true; return $this->_success();
} }
public function prolongerPret($user, $pret_id) { public function prolongerPret($user, $pret_id) {
$session_token = $this->openSessionForUser($user); $session_token = $this->openSessionForUser($user);
if(!$json = $this->httpPost('pmbesSelfServices_self_renew', [$session_token, $pret_id])) if((!$json = $this->httpPost('pmbesSelfServices_self_renew', [$session_token, $pret_id]))
return ['statut' => false, 'erreur' => $this->_('Prolongation impossible : le service de prolongation PMB via webservice est indisponible')]; || (!$result = json_decode($json, true)))
return $this->_error($this->_('Prolongation impossible : le service de prolongation PMB via webservice est indisponible'));
return true; if (array_key_exists('result', $result)
&& is_array($result['result'])
&& array_key_exists('message', $result['result'])
&& $message = $result['result']['message'])
return $this->_error($message);
return $this->_success();
} }
...@@ -339,4 +346,3 @@ class JsonWebClient { ...@@ -339,4 +346,3 @@ class JsonWebClient {
} }
} }
?>
\ No newline at end of file
...@@ -54,7 +54,7 @@ abstract class PMBTestCase extends ModelTestCase { ...@@ -54,7 +54,7 @@ abstract class PMBTestCase extends ModelTestCase {
->whenCalled('httpPost') ->whenCalled('httpPost')
->with('pmbesSelfServices_self_renew', ['faf3404e9d51b48e47745556789b55401', 15]) ->with('pmbesSelfServices_self_renew', ['faf3404e9d51b48e47745556789b55401', 15])
->answers(null) ->answers('{"id":1,"result":{"status":1,"message":"Prolongation non activ\u00e9e","transaction_date":"20190516 164241","title":"7d918cd04e21cb62d886dea49a6b711314","due_date":"20190516 164241"},"error":null}')
->whenCalled('httpPost') ->whenCalled('httpPost')
->with('pmbesOPACEmpr_add_resa', ['faf3404e9d51b48e47745556789b55401', '456789']) ->with('pmbesOPACEmpr_add_resa', ['faf3404e9d51b48e47745556789b55401', '456789'])
...@@ -209,19 +209,23 @@ class PMBServiceTest extends PMBTestCase { ...@@ -209,19 +209,23 @@ class PMBServiceTest extends PMBTestCase {
/** @test */ /** @test */
public function renewLoansShouldReturnError() { public function renewLoansShouldReturnMessageProlongationNonActive() {
$this->assertContains(false, $this->_service->prolongerPret($this->_paul, 15)); $this->assertEquals(['statut' => false,
'erreur' => 'Prolongation non activée'],
$this->_service->prolongerPret($this->_paul, 15));
} }
/** @test */ /** @test */
public function bookingItemShouldReturnSuccess() { public function bookingItemShouldReturnSuccess() {
$this->assertTrue($this->_service->reserverExemplaire($this->_paul, $this->_le_kiosque, '000018')); $this->assertEquals(['statut' => true, 'erreur' => ''],
$this->_service->reserverExemplaire($this->_paul, $this->_le_kiosque, '000018'));
} }
/** @test */ /** @test */
public function cancelBookingShouldReturnSuccess() { public function cancelBookingShouldReturnSuccess() {
$this->assertTrue($this->_service->supprimerReservation($this->_paul, 456)); $this->assertEquals(['statut' => true, 'erreur' => ''],
$this->_service->supprimerReservation($this->_paul, 456));
} }
} }
\ No newline at end of file
Markdown is supported
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