diff --git a/VERSIONS_WIP/133070 b/VERSIONS_WIP/133070 new file mode 100644 index 0000000000000000000000000000000000000000..bf15db1b5e82b05e5964731698cb75eb63d874ba --- /dev/null +++ b/VERSIONS_WIP/133070 @@ -0,0 +1 @@ + - ticket #133070 : Waterbear : correction de la mise à jour du code annexe des exemplaires \ No newline at end of file diff --git a/library/Class/WebService/SIGB/Nanook/GetRecordsResponseReader.php b/library/Class/WebService/SIGB/Nanook/GetRecordsResponseReader.php index 1a7dd60085999ebd9e12845431a66b817340db84..49b39a7439bc1ebe2c7840b2bafe7dcd1bc455a8 100644 --- a/library/Class/WebService/SIGB/Nanook/GetRecordsResponseReader.php +++ b/library/Class/WebService/SIGB/Nanook/GetRecordsResponseReader.php @@ -34,7 +34,7 @@ class Class_WebService_SIGB_Nanook_GetRecordsResponseReader { * @return Class_WebService_SIGB_Nanook_GetRecordsResponseReader */ public static function newInstance() { - return new self(); + return new static(); } @@ -182,5 +182,3 @@ class Nanook_AvailabilityMapper { $map[$availability]($item); } } - -?> \ No newline at end of file diff --git a/library/Class/WebService/SIGB/Nanook/Service.php b/library/Class/WebService/SIGB/Nanook/Service.php index f4f71da4e88bb45555d8b417ba7620abbd782524..dfcc26c2a97bb96ecabe1f2759c16e9f55861693 100644 --- a/library/Class/WebService/SIGB/Nanook/Service.php +++ b/library/Class/WebService/SIGB/Nanook/Service.php @@ -279,15 +279,19 @@ class Class_Webservice_SIGB_Nanook_Service extends Class_WebService_SIGB_Abstrac public function getNotice($id) { try { return $this->ilsdiGetRecords($id, - Class_WebService_SIGB_Nanook_GetRecordsResponseReader::newInstance()); + $this->_getRecordsResponseReader()); } catch (Exception $e) { return; } } - public function testCommunicationStatus() { + protected function _getRecordsResponseReader() { + return Class_WebService_SIGB_Nanook_GetRecordsResponseReader::newInstance(); + } + + public function testCommunicationStatus() { return (false !== strpos($this->test(), '<?xml version="1.0"')) ? static::COMMUNICATION_OK : static::COMMUNICATION_ERROR; @@ -302,7 +306,7 @@ class Class_Webservice_SIGB_Nanook_Service extends Class_WebService_SIGB_Abstrac try { $this ->ilsdiGetRecords(1, - Class_WebService_SIGB_Nanook_GetRecordsResponseReader::newInstance()); + $this->_getRecordsResponseReader()); $httpClient = $this->getWebClient(); $message = $httpClient->getLastRequest(); @@ -481,4 +485,4 @@ class PickupLocationsParamsWithSiteId extends PickupLocationsParams { $params['siteId'] = $item->getCodifAnnexe()->getIdOrigine(); return $params; } -} \ No newline at end of file +} diff --git a/library/Class/WebService/SIGB/Waterbear/GetRecordsResponseReader.php b/library/Class/WebService/SIGB/Waterbear/GetRecordsResponseReader.php new file mode 100644 index 0000000000000000000000000000000000000000..16531260e959a1589827e4665b4841c7440ecef7 --- /dev/null +++ b/library/Class/WebService/SIGB/Waterbear/GetRecordsResponseReader.php @@ -0,0 +1,27 @@ +<?php +/** + * Copyright (c) 2012-2021, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class Class_WebService_SIGB_Waterbear_GetRecordsResponseReader extends Class_WebService_SIGB_Nanook_GetRecordsResponseReader { + public function endLocationId($data) { + $this->_current_item->setCodeAnnexe(trim($data)); + } +} diff --git a/library/Class/WebService/SIGB/Waterbear/Service.php b/library/Class/WebService/SIGB/Waterbear/Service.php index b9e4c24e4209ffad039502225d38b655faccbd42..5b65b850bb254aa4baba64d23b60f99fe95e29f8 100644 --- a/library/Class/WebService/SIGB/Waterbear/Service.php +++ b/library/Class/WebService/SIGB/Waterbear/Service.php @@ -37,4 +37,10 @@ class Class_Webservice_SIGB_Waterbear_Service extends Class_WebService_SIGB_Nano public function providesPickupLocations() { return false; } + + + protected function _getRecordsResponseReader() { + return Class_WebService_SIGB_Waterbear_GetRecordsResponseReader::newInstance(); + } + } diff --git a/tests/fixtures/WaterbearFixtures.php b/tests/fixtures/WaterbearFixtures.php index 9f4f6325dee88dc2508c731adcd4a7d9964b8370..284a1797cc549eca63d16b63fbc90a073840c65b 100644 --- a/tests/fixtures/WaterbearFixtures.php +++ b/tests/fixtures/WaterbearFixtures.php @@ -34,8 +34,8 @@ class WaterbearFixtures { <available>1</available> <holdable>1</holdable> <visible>1</visible> -<locationLabel></locationLabel> -<locationId></locationId> +<locationLabel>Cran</locationLabel> +<locationId>CRAN</locationId> </item> </items> </record> diff --git a/tests/library/Class/WebService/SIGB/WaterbearTest.php b/tests/library/Class/WebService/SIGB/WaterbearTest.php index dde2b2f032a3928478a4593449adb2ec0853e069..21ee5293033d53d2ad5d8c013d920a023c1f1a6b 100644 --- a/tests/library/Class/WebService/SIGB/WaterbearTest.php +++ b/tests/library/Class/WebService/SIGB/WaterbearTest.php @@ -77,7 +77,7 @@ abstract class WaterbearTestCase extends ModelTestCase { $this->fixture('Class_CodifAnnexe' , ['id' => 3, 'libelle' => 'Annexe Cran-Gevrier', 'id_bib' => 3, - 'id_origine' => 10]); + 'id_origine' => 'CRAN']); } } @@ -105,7 +105,6 @@ class WaterbearGetNoticePatacheTest extends WaterbearTestCase { }); Class_WebService_SIGB_AbstractService::setLogger($logger); - $this->_mock_web_client ->whenCalled('open_url') ->with('http://waterbear.org/bib_ws.php?module=externe/ilsdi/GetRecords&ID_notices=9842') @@ -138,4 +137,11 @@ class WaterbearGetNoticePatacheTest extends WaterbearTestCase { public function firstExemplaireCodeBarreShouldBeL023869b() { $this->assertEquals('L-023869b', $this->_notice->exemplaireAt(0)->getCodeBarre()); } -} \ No newline at end of file + + + /** @test */ + public function firstExemplaireCodeAnnexeShouldBeCRAN() { + $this->assertEquals('CRAN', + $this->_notice->exemplaireAt(0)->getCodeAnnexe()); + } +}