diff --git a/cosmogramme/php/_init.php b/cosmogramme/php/_init.php index 63f6b3e1400df544349fe3521076cb0d0a810a33..6fe55ed6b9604db38e3e9a58268071081460be27 100644 --- a/cosmogramme/php/_init.php +++ b/cosmogramme/php/_init.php @@ -1,7 +1,7 @@ <?php error_reporting(E_ERROR | E_PARSE); -define("PATCH_LEVEL","291"); +define("PATCH_LEVEL","292"); define("APPLI","cosmogramme"); define("COSMOPATH", "/var/www/html/vhosts/opac2/www/htdocs"); @@ -20,6 +20,7 @@ define('COM_BIBLIXNET', 10); define('COM_DYNIX', 11); define('COM_CDSCRIPT', 12); define('COM_PMB', 13); +define('COM_WATERBEAR', 14); $basePath = dirname(realpath(__FILE__)); set_include_path(get_include_path() diff --git a/cosmogramme/php/fonctions/objets_saisie.php b/cosmogramme/php/fonctions/objets_saisie.php index cabd0f5f22b4a134f19b9f2696dbd84fba564966..b9e743651c81ea2f5d4fc8b1a29ca762434c7485 100644 --- a/cosmogramme/php/fonctions/objets_saisie.php +++ b/cosmogramme/php/fonctions/objets_saisie.php @@ -97,15 +97,12 @@ function getBlocsParams($id_bib, $type, $valeurs) { return getOuiNon($id, $valeur); }]]; - if(in_array($clef, [COM_PMB])) - $champs_params[0] = ['url_serveur']; - if(in_array($clef, [COM_CDSCRIPT])) $champs_params[0] = ['server_url', 'remote_library_id']; - if (in_array($clef, [COM_VSMART, COM_MICROBIB, COM_BIBLIXNET])) + if (in_array($clef, [COM_PMB, COM_VSMART, COM_MICROBIB, COM_BIBLIXNET, COM_WATERBEAR])) $champs_params[0] = ['url_serveur']; if (in_array($clef, [COM_CARTHAME])) diff --git a/cosmogramme/sql/patch/patch_292.php b/cosmogramme/sql/patch/patch_292.php new file mode 100644 index 0000000000000000000000000000000000000000..e5b35a0a9fc2157468cee482cc5404c292ff05b4 --- /dev/null +++ b/cosmogramme/sql/patch/patch_292.php @@ -0,0 +1,11 @@ +<?php +$adapter = Zend_Db_Table::getDefaultAdapter(); +try { + $adapter->query("update variables set liste='0:Pas informatisé\r\n1:Pergame\r\n2:Paprika\r\n3:Orphée\r\n4:Opsys\r\n5:Microbib\r\n6:Atalante\r\n7:Multilis\r\n8:Bibal\r\n9:Milord\r\n10:Elissa\r\n11:v-smart\r\n12:Koha\r\n13:Nanook\r\n14:Carthame\r\n15:Dynix\r\n16:Cd-Script\r\n17:PMB\r\n18:Waterbear\r\n' where clef='sigb';"); +} catch (Exception $e) {} + +try { + $adapter->query("update variables set liste='0:aucun\r\n1:pergame\r\n2:web-service Opsys\r\n3:serveur Z39.50\r\n4:web-service V-Smart\r\n5:web-service Koha\r\n6:web-service Carthame\r\n7:web-service AFI-Nanook\r\n8:web-service Orphée\r\n9:web-service Microbib\r\n10:web-service BiblixNet\r\n11:web-service Dynix-Symphony\r\n12:Cd-Script\r\n13:PMB\r\n14:web-service Waterbear\r\n' where clef='comm_sigb';"); +} catch (Exception $e) {} + +?> \ No newline at end of file diff --git a/library/Class/IntBib.php b/library/Class/IntBib.php index 213b9ea1bf88fcb518020f184d621f300a90aefc..aa342f5b66b12b54ff8991cb52feb650a5fc6768 100644 --- a/library/Class/IntBib.php +++ b/library/Class/IntBib.php @@ -42,6 +42,7 @@ class Class_IntBib extends Storm_Model_Abstract { const COM_DYNIX = 11; const COM_CDSCRIPT = 12; const COM_PMB = 13; + const COM_WATERBEAR = 14; const SIGB_NONE = 0; const SIGB_PERGAME = 1; @@ -58,7 +59,8 @@ class Class_IntBib extends Storm_Model_Abstract { self::COM_BIBLIXNET => 'Class_WebService_SIGB_BiblixNet', self::COM_DYNIX => 'Class_WebService_SIGB_Dynix', self::COM_CDSCRIPT => 'Class_WebService_SIGB_CdScript', - self::COM_PMB => 'Class_WebService_SIGB_PMB']; + self::COM_PMB => 'Class_WebService_SIGB_PMB', + self::COM_WATERBEAR => 'Class_WebService_SIGB_Waterbear']; protected $_table_name = 'int_bib'; protected $_table_primary = 'id_bib'; diff --git a/library/Class/WebService/SIGB/Waterbear.php b/library/Class/WebService/SIGB/Waterbear.php new file mode 100644 index 0000000000000000000000000000000000000000..33480f65b61a5122b88c65fe8ae51361be2a749e --- /dev/null +++ b/library/Class/WebService/SIGB/Waterbear.php @@ -0,0 +1,25 @@ +<?php +/** + * Copyright (c) 2012-2014, 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 extends Class_WebService_SIGB_Abstract { + +} +?> \ No newline at end of file diff --git a/library/Class/WebService/SIGB/Waterbear/Service.php b/library/Class/WebService/SIGB/Waterbear/Service.php new file mode 100644 index 0000000000000000000000000000000000000000..d58b24a1b906f7749749736a9b2199665363eccc --- /dev/null +++ b/library/Class/WebService/SIGB/Waterbear/Service.php @@ -0,0 +1,38 @@ +<?php +/** + * Copyright (c) 2012-2014, 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_Service extends Class_WebService_SIGB_Nanook_Service { + public function buildQueryURL($options) { + $service = $options['service']; + unset($options['service']); + + return $this->getServerRoot() . $service . '&' . http_build_query($options); + } + + + public function ilsdiGetRecords($id, $reader) { + return $this->httpGetNotice(['service' => 'GetRecords', 'ID_notices' => $id], + $reader); + } + +} + +?> \ No newline at end of file diff --git a/tests/db/UpgradeDBTest.php b/tests/db/UpgradeDBTest.php index 54952b518a423be2757a4639c30faf2c5807e528..010448b738b7cc933b049ff8f8233c9ac7161eae 100644 --- a/tests/db/UpgradeDBTest.php +++ b/tests/db/UpgradeDBTest.php @@ -576,3 +576,25 @@ class UpgradeDB_291_Test extends UpgradeDBTestCase { $this->assertFieldType('custom_field_meta','options_list', 'text'); } } + + + +class UpgradeDB_292_Test extends UpgradeDBTestCase { + public function prepare() { + $this->query("update variables set liste='0:Pas informatisé\r\n1:Pergame\r\n2:Paprika\r\n3:Orphée\r\n4:Opsys\r\n5:Microbib\r\n6:Atalante\r\n7:Multilis\r\n8:Bibal\r\n9:Milord\r\n10:Elissa\r\n11:v-smart\r\n12:Koha\r\n13:Nanook\r\n14:Carthame\r\n15:Dynix\r\n17:PMB\r\n' where clef='sigb';"); + + $this->query("update variables set liste='0:aucun\r\n1:pergame\r\n2:web-service Opsys\r\n3:serveur Z39.50\r\n4:web-service V-Smart\r\n5:web-service Koha\r\n6:web-service Carthame\r\n7:web-service AFI-Nanook\r\n8:web-service Orphée\r\n9:web-service Microbib\r\n10:web-service BiblixNet\r\n11:web-service Dynix-Symphony\r\n13:web-service PMB\r\n' where clef='comm_sigb';"); + } + + + /** @test */ + public function waterbearShouldBePresentInSigbList() { + $this->assertContains("18:Waterbear\r\n", $this->query('select liste from variables where clef = "sigb";')->fetch()['liste']); + } + + + /** @test */ + public function waterbearShouldBePresentInCommSigbList() { + $this->assertContains("14:web-service Waterbear\r\n", $this->query('select liste from variables where clef = "comm_sigb";')->fetch()['liste']); + } +} diff --git a/tests/fixtures/WaterbearFixtures.php b/tests/fixtures/WaterbearFixtures.php new file mode 100644 index 0000000000000000000000000000000000000000..9f4f6325dee88dc2508c731adcd4a7d9964b8370 --- /dev/null +++ b/tests/fixtures/WaterbearFixtures.php @@ -0,0 +1,45 @@ +<?php +/** + * Copyright (c) 2012-2014, 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 WaterbearFixtures { + public static function xmlGetRecordPatache() { + return '<?xml version="1.0" encoding="UTF-8"?> +<GetRecords><record> +<bibId>9842</bibId> +<title>Patache et les objets du jardin</title> +<items> +<item> +<barcode>L-023869b</barcode> +<itemId>12</itemId> +<dueDate></dueDate> +<available>1</available> +<holdable>1</holdable> +<visible>1</visible> +<locationLabel></locationLabel> +<locationId></locationId> +</item> +</items> +</record> +</GetRecords>'; + } +} +?> diff --git a/tests/library/Class/CommSigbTest.php b/tests/library/Class/CommSigbTest.php index 00946db7e10c4c593a7a4f90e13f702bf017a74d..9b2cc13b188fe395a2d33d7f5debe1c3537760ad 100644 --- a/tests/library/Class/CommSigbTest.php +++ b/tests/library/Class/CommSigbTest.php @@ -497,6 +497,32 @@ class CommSigbLocalNanookTest extends CommSigbTestCase { +class CommSigbWaterbearTest extends CommSigbTestCase { + public function setUp() { + parent::setUp(); + + $this->bib_pontault = $this->fixture('Class_IntBib', + ['id' => 5, + 'comm_params' => ['url_serveur' => 'http://waterbear.info/bib_ws.php'], + 'comm_sigb' => Class_IntBib::COM_WATERBEAR]); + + + Class_WebService_SIGB_Waterbear::setService($this->createMockForService('Waterbear')); + } + + + /** @test */ + public function getModeCommShouldReturnAnArrayWithCommParams() { + $this->assertEquals(["url_serveur" => 'http://waterbear.info/bib_ws.php', + "type" => Class_IntBib::COM_WATERBEAR, + 'id_bib' => 5], + $this->bib_pontault->getModeComm(5)); + } +} + + + + class CommSigbCarthameTest extends CommSigbTestCase { public function setUp() { parent::setUp(); diff --git a/tests/library/Class/WebService/SIGB/WaterbearTest.php b/tests/library/Class/WebService/SIGB/WaterbearTest.php new file mode 100644 index 0000000000000000000000000000000000000000..ace6b2d93555ebdee4a8f5271135be928d1d4f50 --- /dev/null +++ b/tests/library/Class/WebService/SIGB/WaterbearTest.php @@ -0,0 +1,135 @@ +<?php +/** + * Copyright (c) 2012, 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 + */ + +include_once 'tests/fixtures/WaterbearFixtures.php'; + + +class WaterbearGetServiceTest extends ModelTestCase { + protected $_storm_default_to_volatile = true; + + + public function setUp() { + Class_WebService_SIGB_Waterbear::reset(); + $this->service = Class_WebService_SIGB_Waterbear::getService( + ['url_serveur' => 'http://waterbear.org/bib_ws.php?module=externe/ilsdi/']); + } + + + /** @test */ + public function getServiceShouldCreateAnInstanceOfWaterbearService() { + $this->assertInstanceOf('Class_WebService_SIGB_Waterbear_Service', + $this->service); + } + + + /** @test */ + public function serverRootShouldBeLocalWaterbearIlsdiService() { + $this->assertEquals('http://waterbear.org/bib_ws.php?module=externe/ilsdi/', + $this->service->getServerRoot()); + } +} + + + +abstract class WaterbearTestCase extends ModelTestCase { + protected + $_mock_web_client, + $_service, + $_storm_default_to_volatile = true; + + public function setUp() { + parent::setUp(); + + $this->_mock_web_client = $this->mock(); + + $this->_service = Class_WebService_SIGB_Waterbear_Service::newInstance() + ->setServerRoot('http://waterbear.org/bib_ws.php?module=externe/ilsdi/') + ->setWebClient($this->_mock_web_client); + + $this->fixture('Class_Bib', + ['id' => 3, + 'libelle' => 'Cran-Gévrier']); + + $this->fixture('Class_CodifAnnexe' , ['id' => 3, + 'libelle' => 'Annexe Cran-Gevrier', + 'id_bib' => 3, + 'code' => 10]); + } +} + + + +class WaterbearGetNoticePatacheTest extends WaterbearTestCase { + protected + $_notice, + $_errors = []; + + public function setUp() { + parent::setUp(); + + $this->fixture('Class_Profil', + ['id' => 1, + 'libelle' => 'default profil'])->beCurrentProfil(); + + $logger = $this->mock() + ->whenCalled('log')->answers(true) + + ->whenCalled('logError') + ->willDo(function($url, $message) + { + $this->_errors []= $url . ':' . $message; + }); + 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') + ->answers(WaterbearFixtures::xmlGetRecordPatache()) + ->beStrict(); + + $this->_notice = $this->_service->getNotice('9842'); + } + + + /** @test */ + public function errorsShouldBeEmpty() { + $this->assertEmpty($this->_errors, implode(';', $this->_errors)); + } + + + /** @test */ + public function noticeIdShouldBe9842() { + $this->assertEquals('9842', $this->_notice->getId()); + } + + + /** @test */ + public function noticeShouldHaveOne() { + $this->assertEquals(1, count($this->_notice->getExemplaires())); + } + + + /** @test */ + public function firstExemplaireCodeBarreShouldBeL023869b() { + $this->assertEquals('L-023869b', $this->_notice->exemplaireAt(0)->getCodeBarre()); + } +} \ No newline at end of file