Commit 55325e25 authored by Laurent's avatar Laurent

Merge branch 'hotline#91532_koha_error_message_update' into 'hotline'

Hotline#91532 koha error message update

See merge request !3170
parents 954ac9c1 f1fc8376
Pipeline #7904 failed with stage
in 33 minutes and 29 seconds
- ticket #91532 : SIGB Koha : mise à jour des message d'erreur affichés en cas d'echec sur une réservation via les webservices.
\ No newline at end of file
...@@ -48,7 +48,10 @@ class Class_WebService_SIGB_Koha_Service extends Class_WebService_SIGB_AbstractR ...@@ -48,7 +48,10 @@ class Class_WebService_SIGB_Koha_Service extends Class_WebService_SIGB_AbstractR
'cannotReserveFromOtherBranches' => $this->_('réservation impossible dans cette bibliothèque'), 'cannotReserveFromOtherBranches' => $this->_('réservation impossible dans cette bibliothèque'),
'tooManyReserves' => $this->_('nombre maximum de réservations atteint'), 'tooManyReserves' => $this->_('nombre maximum de réservations atteint'),
'notReservable' => $this->_('ce document ne peut normalement pas être réservé'), 'notReservable' => $this->_('ce document ne peut normalement pas être réservé'),
'OpacItemHoldNotAllowed' => $this->_('réservation interdite via le portail pour ce document'),
'LocationNotFound' => $this->_('site de retrait introuvable'),
'debarred' => $this->_('compte bloqué'), 'debarred' => $this->_('compte bloqué'),
'PatronDebarred' => $this->_('compte bloqué'),
'expired' => $this->_('compte expiré'), 'expired' => $this->_('compte expiré'),
'alreadyReserved' => $this->_('document déjà réservé sur votre compte'), 'alreadyReserved' => $this->_('document déjà réservé sur votre compte'),
'none_available' => $this->_('aucun document n\'est disponible pour la réservation'), 'none_available' => $this->_('aucun document n\'est disponible pour la réservation'),
...@@ -185,13 +188,6 @@ class Class_WebService_SIGB_Koha_Service extends Class_WebService_SIGB_AbstractR ...@@ -185,13 +188,6 @@ class Class_WebService_SIGB_Koha_Service extends Class_WebService_SIGB_AbstractR
} }
protected function _xmlError($xml) {
return (false !== strpos($xml, 'OpacItemHoldNotAllowed'))
? $this->_('La réservation à l\'exemplaire est interdite')
: '';
}
protected function _setPickupLocation($args, $code) { protected function _setPickupLocation($args, $code) {
if (trim($code) && $annexe = Class_CodifAnnexe::findFirstBy(['code' => $code])) if (trim($code) && $annexe = Class_CodifAnnexe::findFirstBy(['code' => $code]))
$args['pickup_location'] = $annexe->getIdOrigine(); $args['pickup_location'] = $annexe->getIdOrigine();
......
...@@ -751,6 +751,14 @@ class KohaFixtures { ...@@ -751,6 +751,14 @@ class KohaFixtures {
} }
public static function xmlAuthenticatePatronLostCard() {
return '<?xml version="1.0" encoding="UTF-8" ?>
<AuthenticatePatron>
<code>PatronLostCard</code>
</AuthenticatePatron>';
}
public static function xmlGetPatronInfoLaure() { public static function xmlGetPatronInfoLaure() {
return '<?xml version="1.0" encoding="UTF-8" ?> return '<?xml version="1.0" encoding="UTF-8" ?>
<GetPatronInfo> <GetPatronInfo>
......
...@@ -1067,6 +1067,54 @@ class KohaOperationsTest extends KohaTestCase { ...@@ -1067,6 +1067,54 @@ class KohaOperationsTest extends KohaTestCase {
$this->assertEquals(array('statut' => false, 'erreur' => 'Réservation impossible'), $this->assertEquals(array('statut' => false, 'erreur' => 'Réservation impossible'),
$this->service->reserverExemplaire($this->_lafond, $this->_exemplaire_mireille_abeille, '')); $this->service->reserverExemplaire($this->_lafond, $this->_exemplaire_mireille_abeille, ''));
} }
/** @test @see http://forge.afi-sa.fr/issues/91532 */
public function reserverExemplaireShouldBeExplicitIfPatronDebarred() {
$this->mock_web_client
->whenCalled('open_url')
->with('http://cat-aficg55.biblibre.com/cgi-bin/koha/ilsdi.pl?service=HoldTitle&patron_id=572&bib_id=89863&request_location=127.0.0.1')
->answers('<HoldTitle>
<code>PatronDebarred</code>
</HoldTitle>');
$this->assertEquals(
['statut' => false,
'erreur' => 'Réservation impossible : compte bloqué'],
$this->service->reserverExemplaire($this->_lafond, $this->_exemplaire_mireille_abeille, ''));
}
/** @test */
public function reserverExemplaireShouldBeExplicitIfOpacItemHoldNotAllowed() {
$this->mock_web_client
->whenCalled('open_url')
->with('http://cat-aficg55.biblibre.com/cgi-bin/koha/ilsdi.pl?service=HoldTitle&patron_id=572&bib_id=89863&request_location=127.0.0.1')
->answers('<HoldTitle>
<code>OpacItemHoldNotAllowed</code>
</HoldTitle>');
$this->assertEquals(
['statut' => false,
'erreur' => 'Réservation impossible : réservation interdite via le portail pour ce document'],
$this->service->reserverExemplaire($this->_lafond, $this->_exemplaire_mireille_abeille, ''));
}
/** @test */
public function reserverExemplaireShouldBeExplicitIfLocationNotFound() {
$this->mock_web_client
->whenCalled('open_url')
->with('http://cat-aficg55.biblibre.com/cgi-bin/koha/ilsdi.pl?service=HoldTitle&patron_id=572&bib_id=89863&request_location=127.0.0.1')
->answers('<HoldTitle>
<code>LocationNotFound</code>
</HoldTitle>');
$this->assertEquals(
['statut' => false,
'erreur' => 'Réservation impossible : site de retrait introuvable'],
$this->service->reserverExemplaire($this->_lafond, $this->_exemplaire_mireille_abeille, ''));
}
} }
...@@ -1318,6 +1366,13 @@ class KohaAuthenticateWSTest extends KohaTestCase { ...@@ -1318,6 +1366,13 @@ class KohaAuthenticateWSTest extends KohaTestCase {
'password' => '1989']) 'password' => '1989'])
->answers(KohaFixtures::xmlAuthenticatePatronOk()) ->answers(KohaFixtures::xmlAuthenticatePatronOk())
->whenCalled('postData')
->with('http://cat-aficg55.biblibre.com/cgi-bin/koha/ilsdi.pl',
['service' => 'AuthenticatePatron',
'username' => 'gilles',
'password' => '1984'])
->answers(KohaFixtures::xmlAuthenticatePatronLostCard())
->whenCalled('open_url') ->whenCalled('open_url')
->with('http://cat-aficg55.biblibre.com/cgi-bin/koha/ilsdi.pl?service=GetPatronInfo&patron_id=96138&show_contact=1&show_loans=1&show_holds=1') ->with('http://cat-aficg55.biblibre.com/cgi-bin/koha/ilsdi.pl?service=GetPatronInfo&patron_id=96138&show_contact=1&show_loans=1&show_holds=1')
->answers(KohaFixtures::xmlGetPatronInfoDupont()); ->answers(KohaFixtures::xmlGetPatronInfoDupont());
...@@ -1329,9 +1384,19 @@ class KohaAuthenticateWSTest extends KohaTestCase { ...@@ -1329,9 +1384,19 @@ class KohaAuthenticateWSTest extends KohaTestCase {
'idabon' => 'john', 'idabon' => 'john',
'id_site' => 3]); 'id_site' => 3]);
$this->user_lost = $this->fixture('Class_Users', ['id' => 11,
'login' => 'gilles',
'password' => '1984',
'role_level' => ZendAfi_Acl_AdminControllerRoles::ABONNE_SIGB,
'idabon' => 'gilles',
'id_site' => 3]);
$this->emprunteur = $this->service->getEmprunteur($this->user); $this->emprunteur = $this->service->getEmprunteur($this->user);
$this->emprunteur_lost = $this->service->getEmprunteur($this->user_lost);
$this->emprunteur->updateUser($this->user); $this->emprunteur->updateUser($this->user);
$this->emprunteur_lost->updateUser($this->user_lost);
} }
public function expectedUser() { public function expectedUser() {
...@@ -1359,6 +1424,18 @@ class KohaAuthenticateWSTest extends KohaTestCase { ...@@ -1359,6 +1424,18 @@ class KohaAuthenticateWSTest extends KohaTestCase {
} }
/** @test */
public function userWithLostCardShouldThrowError() {
$this->mock_web_client
->whenCalled('postData')
->with('http://cat-aficg55.biblibre.com/cgi-bin/koha/ilsdi.pl',
['service' => 'AuthenticatePatron',
'username' => 'john',
'password' => '1989'])
->answers(KohaFixtures::xmlAuthenticatePatronLostCard());
$this->assertFalse($this->emprunteur_lost->isValid());
}
} }
......
...@@ -181,12 +181,10 @@ class HandleBranchcodeHoldItemAndHoldTitleTest extends HandleBranchcodeTestCase ...@@ -181,12 +181,10 @@ class HandleBranchcodeHoldItemAndHoldTitleTest extends HandleBranchcodeTestCase
->whenCalled('open_url') ->whenCalled('open_url')
->with($this->ilsdi . '?service=HoldItem&item_id=&pickup_location=CHY-GB') ->with($this->ilsdi . '?service=HoldItem&item_id=&pickup_location=CHY-GB')
->willDo(function() {$this->expected_call [] = 1; ->willDo(function() {$this->expected_call [] = 1;
return '<HoldTitle> return '<HoldItem>
<title>Mireille l\'abeille</title> <code>OpacItemHoldNotAllowed</code>
<pickup_location>Bibliothèque Départementale de la Meuse</pickup_location> </HoldItem>';
<HoldItem>OpacItemHoldNotAllowed</HoldItem> })
</HoldTitle>';
})
->whenCalled('open_url') ->whenCalled('open_url')
->with($this->ilsdi . '?service=HoldTitle&request_location=127.0.0.1&pickup_location=CHY-GB') ->with($this->ilsdi . '?service=HoldTitle&request_location=127.0.0.1&pickup_location=CHY-GB')
......
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