Skip to content
Snippets Groups Projects
Commit f2db33eb authored by Patrick Barroca's avatar Patrick Barroca :grin:
Browse files

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 !3134
parents 34216b14 cd891ae4
Branches
Tags
3 merge requests!3297WIP: Master,!3141Hotline,!3134hotline #92518 PMB : display renew loan error messages
Pipeline #7067 passed with stage
in 35 minutes and 40 seconds
- 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
$exemplaire->getIdOrigine()]);
$result = (array) $this->_getJsonData($json, 'result');
if(!$result)
return ['status' => false, 'erreur' => $this->_('Réservation impossible : le service de réservation PMB via webservice est indisponible')];
if (!$result)
return $this->_error($this->_('Réservation impossible : le service de réservation PMB via webservice est indisponible'));
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
$session_token = $this->openSessionForUser($user);
$json = $this->httpPost('pmbesOPACEmpr_delete_resa', [$session_token,
$reservation_id]);
return true;
return $this->_success();
}
public function prolongerPret($user, $pret_id) {
$session_token = $this->openSessionForUser($user);
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')];
if((!$json = $this->httpPost('pmbesSelfServices_self_renew', [$session_token, $pret_id]))
|| (!$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 {
}
}
?>
\ No newline at end of file
......@@ -54,7 +54,7 @@ abstract class PMBTestCase extends ModelTestCase {
->whenCalled('httpPost')
->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')
->with('pmbesOPACEmpr_add_resa', ['faf3404e9d51b48e47745556789b55401', '456789'])
......@@ -209,19 +209,23 @@ class PMBServiceTest extends PMBTestCase {
/** @test */
public function renewLoansShouldReturnError() {
$this->assertContains(false, $this->_service->prolongerPret($this->_paul, 15));
public function renewLoansShouldReturnMessageProlongationNonActive() {
$this->assertEquals(['statut' => false,
'erreur' => 'Prolongation non activée'],
$this->_service->prolongerPret($this->_paul, 15));
}
/** @test */
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 */
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
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