From a947a14a29b232e631157a0b138e1f98e9562763 Mon Sep 17 00:00:00 2001 From: Henri-Damien LAURENT <hdlaurent@afi-sa.net> Date: Thu, 25 Apr 2024 15:18:57 +0000 Subject: [PATCH] hotline#201164 : Koha : message was not really helpful when new webService Call Failed --- VERSIONS_HOTLINE/201164 | 1 + .../opac/controllers/RechercheController.php | 8 ++-- .../WebService/SIGB/KohaCommunityTest.php | 37 +++++++++++++++++++ .../HandleBranchcodeKohaCommunityTest.php | 2 +- 4 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 VERSIONS_HOTLINE/201164 diff --git a/VERSIONS_HOTLINE/201164 b/VERSIONS_HOTLINE/201164 new file mode 100644 index 00000000000..4f4df5bea7d --- /dev/null +++ b/VERSIONS_HOTLINE/201164 @@ -0,0 +1 @@ + - correctif #201164 : Koha : quand le webservice Koha échoue, la liste des sites de retrait possible est maintenant vide. \ No newline at end of file diff --git a/application/modules/opac/controllers/RechercheController.php b/application/modules/opac/controllers/RechercheController.php index 3b58d1d40a3..76d9987ac06 100644 --- a/application/modules/opac/controllers/RechercheController.php +++ b/application/modules/opac/controllers/RechercheController.php @@ -815,10 +815,12 @@ class RechercheController extends ZendAfi_Controller_Action { $first = ''; $locations = $comm->pickupLocationsFor($user, $item); - foreach($locations as $k => $v) { - $first = $first ? $first : $k; + if (isset($locations['statut']) && !$locations['statut']) + return []; + + foreach($locations as $k => $v) $element->addMultiOption($k, $v); - } + return $locations; } diff --git a/tests/library/Class/WebService/SIGB/KohaCommunityTest.php b/tests/library/Class/WebService/SIGB/KohaCommunityTest.php index fd92e3f13bc..e55d3cd6e03 100644 --- a/tests/library/Class/WebService/SIGB/KohaCommunityTest.php +++ b/tests/library/Class/WebService/SIGB/KohaCommunityTest.php @@ -771,6 +771,43 @@ class KohaCommunityPickupLocationsWithAnnexeTest extends KohaCommunityTestCase +class KohaCommunityPickupLocationsErrorAuthenticationTest extends KohaCommunityTestCase +{ + + public function setUp() + { + parent::setUp(); + + Class_HttpClientFactory::getInstance() + ->getLastHttpClient() + ->addRequestWithResponse('https://koha-community:443/ilsdi.pl?service=GetPatronInfo&patron_id=96138&show_contact=1&show_loans=0&show_holds=1', + KohaFixtures::xmlGetPatronInfoLaure()) + + ->addRequestWithResponse('https://koha-community:443/ilsdi.pl/items/96630/pickup_locations?_match=exact&patron_id=572', + '{"error":"authentication failure"}'); + + Class_CosmoVar::set('site_retrait_resa', 1); + + $this->fixture(Class_Exemplaire::class, + ['id' => 2, + 'id_origine' => 96629, + 'zone995' => serialize([['clef' => '9', + 'valeur' => '96630']])]); + + $this->dispatch('recherche/reservation-pickup-ajax/copy_id/2/code_annexe/IEPG'); + } + + + /** @test */ + public function errorShouldPasDeBibliothequeDeRetraitDisponible() + { + $this->assertXPathContentContainsFromJson('//p[@class="error"]', 'Aucun site de retrait disponible'); + } +} + + + + class KohaCommunityPickupLocationsWithoutAnnexeTest extends KohaCommunityTestCase { public function setUp() diff --git a/tests/scenarios/HandleBranchcode/HandleBranchcodeKohaCommunityTest.php b/tests/scenarios/HandleBranchcode/HandleBranchcodeKohaCommunityTest.php index 4bc94ef5651..03069653d8c 100644 --- a/tests/scenarios/HandleBranchcode/HandleBranchcodeKohaCommunityTest.php +++ b/tests/scenarios/HandleBranchcode/HandleBranchcodeKohaCommunityTest.php @@ -122,7 +122,7 @@ class HandleBranchcodeKohaCommunityWithItemPickupLocationAndSIGBProvidesLocation /** @test */ public function requestShouldBeForwaredtoReservationAjax() { - $this->assertContains('form', $this->_response->getBody()); + $this->assertContains('"title":"Lieu de mise ', $this->_response->getBody()); } -- GitLab