Skip to content
Snippets Groups Projects
Commit 785b0106 authored by Laurent's avatar Laurent
Browse files

sandbox: add support for Waterbear web services

parent 142c2a8a
Branches
Tags
3 merge requests!1659Master,!1595Master,!1583Waterbear ws
<?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()
......
......@@ -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]))
......
<?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
......@@ -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';
......
<?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
<?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
......@@ -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']);
}
}
<?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>';
}
}
?>
......@@ -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();
......
<?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 Storm_Test_ModelTestCase {
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 Storm_Test_ModelTestCase {
protected
$_mock_web_client,
$_service;
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
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