From 9b7886f5e2bea822956368c7f5093f65c3e3a871 Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Wed, 29 Aug 2012 16:36:41 -0400 Subject: [PATCH] Changed ILS driver loading sequence for more flexibility. No hard work is done in the constructor; instead there is an init() method that gets called by the VuFind\ILS\Connection class. Additionally, drivers no longer load their own configurations; instead, configs are pushed in by VuFind\ILS\Connection, making reuse easier in other contexts. Finally, ILS drivers all inherit from the same base class, easing future functionality. PICA configuration now includes copy of DAIA settings -- this avoids the need to load two separate configs when using PICA.ini Fixed a Symphony namespacing bug. Stub tests have been added for all existing drivers, though they do not cover much code yet. --- config/vufind/PICA.ini | 3 + module/VuFind/src/VuFind/ILS/Connection.php | 22 +++++- .../src/VuFind/ILS/Driver/AbstractBase.php | 57 +++++++++++++ module/VuFind/src/VuFind/ILS/Driver/Aleph.php | 79 +++++++++++-------- .../VuFind/src/VuFind/ILS/Driver/Amicus.php | 26 +++--- module/VuFind/src/VuFind/ILS/Driver/DAIA.php | 26 +++--- module/VuFind/src/VuFind/ILS/Driver/Demo.php | 26 +++--- .../src/VuFind/ILS/Driver/DriverInterface.php | 22 ++++++ .../src/VuFind/ILS/Driver/Evergreen.php | 28 +++---- .../VuFind/src/VuFind/ILS/Driver/Horizon.php | 24 +++--- .../src/VuFind/ILS/Driver/HorizonXMLAPI.php | 13 +-- .../src/VuFind/ILS/Driver/Innovative.php | 26 +++--- module/VuFind/src/VuFind/ILS/Driver/Koha.php | 38 ++++----- .../src/VuFind/ILS/Driver/NewGenLib.php | 25 +++--- module/VuFind/src/VuFind/ILS/Driver/NoILS.php | 23 +++--- module/VuFind/src/VuFind/ILS/Driver/PICA.php | 32 +++----- .../VuFind/src/VuFind/ILS/Driver/Sample.php | 12 ++- .../VuFind/src/VuFind/ILS/Driver/Symphony.php | 24 +++--- .../VuFind/src/VuFind/ILS/Driver/Unicorn.php | 79 +++++++++---------- .../VuFind/src/VuFind/ILS/Driver/Virtua.php | 25 +++--- .../VuFind/src/VuFind/ILS/Driver/Voyager.php | 25 +++--- .../src/VuFind/ILS/Driver/VoyagerRestful.php | 14 ++-- .../VuFind/src/VuFind/ILS/Driver/XCNCIP.php | 29 +++---- .../VuFind/src/VuFind/ILS/Driver/XCNCIP2.php | 29 +++---- module/VuFind/tests/ILS/Driver/AlephTest.php | 62 +++++++++++++++ module/VuFind/tests/ILS/Driver/AmicusTest.php | 62 +++++++++++++++ module/VuFind/tests/ILS/Driver/DAIATest.php | 62 +++++++++++++++ module/VuFind/tests/ILS/Driver/DemoTest.php | 63 +++++++++++++++ .../VuFind/tests/ILS/Driver/EvergreenTest.php | 62 +++++++++++++++ .../VuFind/tests/ILS/Driver/HorizonTest.php | 62 +++++++++++++++ .../tests/ILS/Driver/HorizonXMLAPITest.php | 62 +++++++++++++++ .../tests/ILS/Driver/InnovativeTest.php | 62 +++++++++++++++ module/VuFind/tests/ILS/Driver/KohaTest.php | 62 +++++++++++++++ .../VuFind/tests/ILS/Driver/NewGenLibTest.php | 62 +++++++++++++++ module/VuFind/tests/ILS/Driver/NoILSTest.php | 62 +++++++++++++++ module/VuFind/tests/ILS/Driver/PICATest.php | 62 +++++++++++++++ module/VuFind/tests/ILS/Driver/SampleTest.php | 63 +++++++++++++++ .../VuFind/tests/ILS/Driver/SymphonyTest.php | 66 ++++++++++++++++ .../VuFind/tests/ILS/Driver/UnicornTest.php | 62 +++++++++++++++ module/VuFind/tests/ILS/Driver/VirtuaTest.php | 62 +++++++++++++++ .../tests/ILS/Driver/VoyagerRestfulTest.php | 62 +++++++++++++++ .../VuFind/tests/ILS/Driver/VoyagerTest.php | 62 +++++++++++++++ .../VuFind/tests/ILS/Driver/XCNCIP2Test.php | 62 +++++++++++++++ module/VuFind/tests/ILS/Driver/XCNCIPTest.php | 62 +++++++++++++++ 44 files changed, 1612 insertions(+), 341 deletions(-) create mode 100644 module/VuFind/src/VuFind/ILS/Driver/AbstractBase.php create mode 100644 module/VuFind/tests/ILS/Driver/AlephTest.php create mode 100644 module/VuFind/tests/ILS/Driver/AmicusTest.php create mode 100644 module/VuFind/tests/ILS/Driver/DAIATest.php create mode 100644 module/VuFind/tests/ILS/Driver/DemoTest.php create mode 100644 module/VuFind/tests/ILS/Driver/EvergreenTest.php create mode 100644 module/VuFind/tests/ILS/Driver/HorizonTest.php create mode 100644 module/VuFind/tests/ILS/Driver/HorizonXMLAPITest.php create mode 100644 module/VuFind/tests/ILS/Driver/InnovativeTest.php create mode 100644 module/VuFind/tests/ILS/Driver/KohaTest.php create mode 100644 module/VuFind/tests/ILS/Driver/NewGenLibTest.php create mode 100644 module/VuFind/tests/ILS/Driver/NoILSTest.php create mode 100644 module/VuFind/tests/ILS/Driver/PICATest.php create mode 100644 module/VuFind/tests/ILS/Driver/SampleTest.php create mode 100644 module/VuFind/tests/ILS/Driver/SymphonyTest.php create mode 100644 module/VuFind/tests/ILS/Driver/UnicornTest.php create mode 100644 module/VuFind/tests/ILS/Driver/VirtuaTest.php create mode 100644 module/VuFind/tests/ILS/Driver/VoyagerRestfulTest.php create mode 100644 module/VuFind/tests/ILS/Driver/VoyagerTest.php create mode 100644 module/VuFind/tests/ILS/Driver/XCNCIP2Test.php create mode 100644 module/VuFind/tests/ILS/Driver/XCNCIPTest.php diff --git a/config/vufind/PICA.ini b/config/vufind/PICA.ini index 0a7a10dcba2..3b4e9532692 100644 --- a/config/vufind/PICA.ini +++ b/config/vufind/PICA.ini @@ -1,3 +1,6 @@ +[Global] +baseUrl = [your DAIA server base url] + [Catalog] Host = "[your OPC Host]" DB = 1 ; You may need to change this to the ID of your OPC DB diff --git a/module/VuFind/src/VuFind/ILS/Connection.php b/module/VuFind/src/VuFind/ILS/Connection.php index cf493e3f26e..adec157af0f 100644 --- a/module/VuFind/src/VuFind/ILS/Connection.php +++ b/module/VuFind/src/VuFind/ILS/Connection.php @@ -59,7 +59,7 @@ class Connection * * @var object */ - protected $driver; + protected $driver = false; /** * Constructor @@ -88,6 +88,7 @@ class Connection try { $this->getDriver(); } catch (\Exception $e) { + $this->driver = false; $this->driverClass = 'VuFind\ILS\Driver\NoILS'; } } @@ -103,10 +104,29 @@ class Connection { if (!$this->driver) { $this->driver = new $this->driverClass; + $this->driver->setConfig($this->getDriverConfig()); + $this->driver->init(); } return $this->driver; } + /** + * Get configuration for the ILS driver. We will load an .ini file named + * after the driver class if it exists; otherwise we will return an empty + * array. + * + * @return array + */ + public function getDriverConfig() + { + // Determine config file name based on class name: + $parts = explode('\\', $this->driverClass); + $configFile = end($parts) . '.ini'; + $configFilePath = ConfigReader::getConfigPath($configFile); + return file_exists($configFilePath) + ? parse_ini_file($configFilePath, true) : array(); + } + /** * Check Function * diff --git a/module/VuFind/src/VuFind/ILS/Driver/AbstractBase.php b/module/VuFind/src/VuFind/ILS/Driver/AbstractBase.php new file mode 100644 index 00000000000..fa394ab5fa0 --- /dev/null +++ b/module/VuFind/src/VuFind/ILS/Driver/AbstractBase.php @@ -0,0 +1,57 @@ +<?php +/** + * Default ILS driver base class. + * + * PHP version 5 + * + * Copyright (C) Villanova University 2007. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @category VuFind2 + * @package ILS_Drivers + * @author Andrew S. Nagy <vufind-tech@lists.sourceforge.net> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/building_an_ils_driver Wiki + */ +namespace VuFind\ILS\Driver; + +/** + * Default ILS driver base class. + * + * @category VuFind2 + * @package ILS_Drivers + * @author Andrew S. Nagy <vufind-tech@lists.sourceforge.net> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/building_an_ils_driver Wiki + */ +abstract class AbstractBase implements DriverInterface +{ + protected $config = array(); + + /** + * Set configuration. + * + * Set the configuration for the driver. + * + * @param array $config Configuration array (usually loaded from a VuFind .ini + * file whose name corresponds with the driver class name). + * + * @return void + */ + public function setConfig($config) + { + $this->config = $config; + } +} diff --git a/module/VuFind/src/VuFind/ILS/Driver/Aleph.php b/module/VuFind/src/VuFind/ILS/Driver/Aleph.php index 5755208d696..f33af8de60e 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/Aleph.php +++ b/module/VuFind/src/VuFind/ILS/Driver/Aleph.php @@ -271,61 +271,72 @@ class AlephRestfulException extends \Exception * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @link http://vufind.org/wiki/building_an_ils_driver Wiki */ -class Aleph implements DriverInterface +class Aleph extends AbstractBase { + protected $duedates = false; protected $translator = false; /** - * Constructor + * Initialize the driver. + * + * Validate configuration and perform all resource-intensive tasks needed to + * make the driver active. * - * @param string $configFile The location of an alternative config file + * @throws ILSException + * @return void */ - public function __construct($configFile = false) + public function init() { - // Load configuration file: - if (!$configFile) { - $configFile = 'Aleph.ini'; + // Validate config + $required = array( + 'host', 'bib', 'useradm', 'admlib', 'dlfport', 'available_statuses' + ); + foreach ($required as $current) { + if (!isset($this->config['Catalog'][$current])) { + throw new ILSException("Missing Catalog/{$current} config setting."); + } } - $configFilePath = ConfigReader::getConfigPath($configFile); - if (!file_exists($configFilePath)) { - throw new ILSException( - 'Cannot access config file - ' . $configFilePath - ); + if (!isset($this->config['sublibadm'])) { + throw new ILSException('Missing sublibadm config setting.'); } - $configArray = parse_ini_file($configFilePath, true); - $this->host = $configArray['Catalog']['host']; - $this->bib = split(',', $configArray['Catalog']['bib']); - $this->useradm = $configArray['Catalog']['useradm']; - $this->admlib = $configArray['Catalog']['admlib']; - if (isset($configArray['Catalog']['wwwuser']) - && isset($configArray['Catalog']['wwwpasswd']) + + // Process config + $this->host = $this->config['Catalog']['host']; + $this->bib = split(',', $this->config['Catalog']['bib']); + $this->useradm = $this->config['Catalog']['useradm']; + $this->admlib = $this->config['Catalog']['admlib']; + if (isset($this->config['Catalog']['wwwuser']) + && isset($this->config['Catalog']['wwwpasswd']) ) { - $this->wwwuser = $configArray['Catalog']['wwwuser']; - $this->wwwpasswd = $configArray['Catalog']['wwwpasswd']; + $this->wwwuser = $this->config['Catalog']['wwwuser']; + $this->wwwpasswd = $this->config['Catalog']['wwwpasswd']; $this->xserver_enabled = true; } else { $this->xserver_enabled = false; } - $this->dlfport = $configArray['Catalog']['dlfport']; - $this->sublibadm = $configArray['sublibadm']; - if (isset($configArray['duedates'])) { - $this->duedates = $configArray['duedates']; + $this->dlfport = $this->config['Catalog']['dlfport']; + $this->sublibadm = $this->config['sublibadm']; + if (isset($this->config['duedates'])) { + $this->duedates = $this->config['duedates']; } $this->available_statuses - = split(',', $configArray['Catalog']['available_statuses']); - $this->quick_availability = $configArray['Catalog']['quick_availability']; - $this->debug_enabled = $configArray['Catalog']['debug']; - if (isset($configArray['util']['tab40']) - && isset($configArray['util']['tab15']) - && isset($configArray['util']['tab_sub_library']) + = split(',', $this->config['Catalog']['available_statuses']); + $this->quick_availability + = isset($this->config['Catalog']['quick_availability']) + ? $this->config['Catalog']['quick_availability'] : false; + $this->debug_enabled = isset($this->config['Catalog']['debug']) + ? $this->config['Catalog']['debug'] : false; + if (isset($this->config['util']['tab40']) + && isset($this->config['util']['tab15']) + && isset($this->config['util']['tab_sub_library']) ) { - if (isset($configArray['Cache']['type'])) { + if (isset($this->config['Cache']['type'])) { $manager = CacheManager::getInstance(); - $cache = $manager->getCache($configArray['Cache']['type']); + $cache = $manager->getCache($this->config['Cache']['type']); $this->translator = $cache->getItem('alephTranslator'); } if ($this->translator == false) { - $this->translator = new AlephTranslator($configArray); + $this->translator = new AlephTranslator($this->config); if (isset($cache)) { $cache->setItem('alephTranslator', $this->translator); } diff --git a/module/VuFind/src/VuFind/ILS/Driver/Amicus.php b/module/VuFind/src/VuFind/ILS/Driver/Amicus.php index 21b78dabfdd..9236af8768b 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/Amicus.php +++ b/module/VuFind/src/VuFind/ILS/Driver/Amicus.php @@ -38,33 +38,27 @@ use PDO, PDOException, VuFind\Config\Reader as ConfigReader, * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @link http://vufind.org/wiki/building_an_ils_driver Wiki */ -class Amicus implements DriverInterface +class Amicus extends AbstractBase { protected $db; - protected $config; protected $statusRankings = false; // used by _pickStatus() method /** - * Constructor + * Initialize the driver. * - * @param string $configFile The location of an alternative config file + * Validate configuration and perform all resource-intensive tasks needed to + * make the driver active. + * + * @throws ILSException + * @return void */ - public function __construct($configFile = false) + public function init() { - // Load configuration file: - if (!$configFile) { - $configFile = 'Amicus.ini'; + if (empty($this->config)) { + throw new ILSException('Configuration needs to be set.'); } - $configFilePath = ConfigReader::getConfigPath($configFile); - if (!file_exists($configFilePath)) { - throw new ILSException( - 'Cannot access config file - ' . $configFilePath - ); - } - $this->config = parse_ini_file($configFilePath, true); // Define Database Name - $tns = '(DESCRIPTION=' . '(ADDRESS_LIST=' . '(ADDRESS=' . diff --git a/module/VuFind/src/VuFind/ILS/Driver/DAIA.php b/module/VuFind/src/VuFind/ILS/Driver/DAIA.php index 5da06062855..fcde26241c7 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/DAIA.php +++ b/module/VuFind/src/VuFind/ILS/Driver/DAIA.php @@ -42,30 +42,26 @@ use DOMDocument, VuFind\Config\Reader as ConfigReader, * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @link http://vufind.org/wiki/building_an_ils_driver Wiki */ -class DAIA implements DriverInterface +class DAIA extends AbstractBase { protected $baseURL; /** - * Constructor + * Initialize the driver. * - * @param string $configFile The location of an alternative config file + * Validate configuration and perform all resource-intensive tasks needed to + * make the driver active. + * + * @throws ILSException + * @return void */ - public function __construct($configFile = false) + public function init() { - // Load configuration file: - if (!$configFile) { - $configFile = 'DAIA.ini'; - } - $configFilePath = ConfigReader::getConfigPath($configFile); - if (!file_exists($configFilePath)) { - throw new ILSException( - 'Cannot access config file - ' . $configFilePath - ); + if (!isset($this->config['Global']['baseUrl'])) { + throw new ILSException('Global/baseUrl configuration needs to be set.'); } - $configArray = parse_ini_file($configFilePath, true); - $this->baseURL = $configArray['Global']['baseUrl']; + $this->baseURL = $this->config['Global']['baseUrl']; } /** diff --git a/module/VuFind/src/VuFind/ILS/Driver/Demo.php b/module/VuFind/src/VuFind/ILS/Driver/Demo.php index 23579c951d1..f748a53d052 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/Demo.php +++ b/module/VuFind/src/VuFind/ILS/Driver/Demo.php @@ -47,7 +47,7 @@ use ArrayObject, VuFind\Config\Reader as ConfigReader, * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @link http://vufind.org/wiki/building_an_ils_driver Wiki */ -class Demo implements DriverInterface +class Demo extends AbstractBase { // Used when getting random bib ids from solr protected $db; @@ -58,24 +58,18 @@ class Demo implements DriverInterface protected $idsInMyResearch = true; /** - * Constructor + * Initialize the driver. * - * @param string $configFile The location of an alternative config file + * Validate configuration and perform all resource-intensive tasks needed to + * make the driver active. + * + * @throws ILSException + * @return void */ - public function __construct($configFile = false) + public function init() { - // Load configuration file in case user has special preferences (but don't - // worry if it's missing): - if (!$configFile) { - $configFile = 'Demo.ini'; - } - $configFilePath = ConfigReader::getConfigPath($configFile); - if (file_exists($configFilePath)) { - $configArray = parse_ini_file($configFilePath, true); - if (isset($configArray['Catalog']['idsInMyResearch'])) { - $this->idsInMyResearch - = $configArray['Catalog']['idsInMyResearch']; - } + if (isset($this->config['Catalog']['idsInMyResearch'])) { + $this->idsInMyResearch = $this->config['Catalog']['idsInMyResearch']; } // Establish a namespace in the session for persisting fake data (to save diff --git a/module/VuFind/src/VuFind/ILS/Driver/DriverInterface.php b/module/VuFind/src/VuFind/ILS/Driver/DriverInterface.php index a8f632cad49..67958a7d801 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/DriverInterface.php +++ b/module/VuFind/src/VuFind/ILS/Driver/DriverInterface.php @@ -46,6 +46,28 @@ namespace VuFind\ILS\Driver; */ interface DriverInterface { + /** + * Set configuration. + * + * Set the configuration for the driver. + * + * @param array $config Configuration array (usually loaded from a VuFind .ini + * file whose name corresponds with the driver class name). + * + * @return void + */ + public function setConfig($config); + + /** + * Initialize the driver. + * + * Validate configuration and perform all resource-intensive tasks needed to + * make the driver active. + * + * @return void + */ + public function init(); + /** * Get Status * diff --git a/module/VuFind/src/VuFind/ILS/Driver/Evergreen.php b/module/VuFind/src/VuFind/ILS/Driver/Evergreen.php index 69d449ad157..b39275096b3 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/Evergreen.php +++ b/module/VuFind/src/VuFind/ILS/Driver/Evergreen.php @@ -41,30 +41,26 @@ use PDO, PDOException, VuFind\Config\Reader as ConfigReader, * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @link http://vufind.org/wiki/building_an_ils_driver Wiki */ -class Evergreen implements DriverInterface +class Evergreen extends AbstractBase { protected $db; protected $dbName; - protected $config; - /** - * Constructor + /** + * Initialize the driver. + * + * Validate configuration and perform all resource-intensive tasks needed to + * make the driver active. * - * @param string $configFile The location of an alternative config file + * @throws ILSException + * @throws PDOException + * @return void */ - public function __construct($configFile = false) + public function init() { - // Load configuration file: - if (!$configFile) { - $configFile = 'Evergreen.ini'; - } - $configFilePath = ConfigReader::getConfigPath($configFile); - if (!file_exists($configFilePath)) { - throw new ILSException( - 'Cannot access config file - ' . $configFilePath - ); + if (empty($this->config)) { + throw new ILSException('Configuration needs to be set.'); } - $this->config = parse_ini_file($configFilePath, true); // Define Database Name $this->dbName = $this->config['Catalog']['database']; diff --git a/module/VuFind/src/VuFind/ILS/Driver/Horizon.php b/module/VuFind/src/VuFind/ILS/Driver/Horizon.php index 984ddff0850..b4ba3c0367f 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/Horizon.php +++ b/module/VuFind/src/VuFind/ILS/Driver/Horizon.php @@ -39,31 +39,25 @@ use VuFind\Config\Reader as ConfigReader, VuFind\Exception\ILS as ILSException; * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @link http://vufind.org/wiki/building_an_ils_driver Wiki */ -class Horizon implements DriverInterface +class Horizon extends AbstractBase { protected $dateFormat; protected $db; - protected $config; /** - * Constructor + * Initialize the driver. * - * @param string $configFile An alternative config file name + * Validate configuration and perform all resource-intensive tasks needed to + * make the driver active. * - * @access public + * @throws ILSException + * @return void */ - public function __construct($configFile = false) + public function init() { - if (!$configFile) { - $configFile = "Horizon.ini"; - } - $configFilePath = ConfigReader::getConfigPath($configFile); - if (!file_exists($configFilePath)) { - throw new ILSException( - 'Cannot access config file - ' . $configFilePath - ); + if (empty($this->config)) { + throw new ILSException('Configuration needs to be set.'); } - $this->config = parse_ini_file($configFilePath, true); // Connect to database $this->db = mssql_pconnect( diff --git a/module/VuFind/src/VuFind/ILS/Driver/HorizonXMLAPI.php b/module/VuFind/src/VuFind/ILS/Driver/HorizonXMLAPI.php index 29b8efeeb34..a1d7a4a2fdb 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/HorizonXMLAPI.php +++ b/module/VuFind/src/VuFind/ILS/Driver/HorizonXMLAPI.php @@ -42,14 +42,17 @@ use VuFind\Exception\ILS as ILSException, VuFind\Http\Client as HttpClient; class HorizonXMLAPI extends Horizon { /** - * Constructor + * Initialize the driver. * - * @param string $configFile An alternative config file name + * Validate configuration and perform all resource-intensive tasks needed to + * make the driver active. + * + * @throws ILSException + * @return void */ - public function __construct($configFile = 'HorizonXMLAPI.ini') + public function init() { - // Call the parent's constructor... - parent::__construct($configFile); + parent::init(); // Process Config $this->wsProfile = $this->config['Webservices']['profile']; diff --git a/module/VuFind/src/VuFind/ILS/Driver/Innovative.php b/module/VuFind/src/VuFind/ILS/Driver/Innovative.php index e379450db58..54a487eb002 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/Innovative.php +++ b/module/VuFind/src/VuFind/ILS/Driver/Innovative.php @@ -41,28 +41,22 @@ use VuFind\Config\Reader as ConfigReader, VuFind\Exception\ILS as ILSException, * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @link http://vufind.org/wiki/building_an_ils_driver Wiki */ -class Innovative implements DriverInterface +class Innovative extends AbstractBase { - public $config; - /** - * Constructor + * Initialize the driver. + * + * Validate configuration and perform all resource-intensive tasks needed to + * make the driver active. * - * @param string $configFile The location of an alternative config file + * @throws ILSException + * @return void */ - public function __construct($configFile = false) + public function init() { - // Load configuration file: - if (!$configFile) { - $configFile = 'Innovative.ini'; - } - $configFilePath = ConfigReader::getConfigPath($configFile); - if (!file_exists($configFilePath)) { - throw new ILSException( - 'Cannot access config file - ' . $configFilePath - ); + if (empty($this->config)) { + throw new ILSException('Configuration needs to be set.'); } - $this->config = parse_ini_file($configFilePath, true); } /** diff --git a/module/VuFind/src/VuFind/ILS/Driver/Koha.php b/module/VuFind/src/VuFind/ILS/Driver/Koha.php index 7a7417636c2..eeac7c0725a 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/Koha.php +++ b/module/VuFind/src/VuFind/ILS/Driver/Koha.php @@ -42,38 +42,34 @@ use PDO, PDOException, VuFind\Config\Reader as ConfigReader, * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @link http://vufind.org/wiki/building_an_ils_driver Wiki */ -class Koha implements DriverInterface +class Koha extends AbstractBase { protected $db; protected $ilsBaseUrl; protected $locCodes; /** - * Constructor + * Initialize the driver. * - * @param string $configFile The location of an alternative config file + * Validate configuration and perform all resource-intensive tasks needed to + * make the driver active. + * + * @throws ILSException + * @return void */ - public function __construct($configFile = false) + public function init() { - // Load configuration file: - if (!$configFile) { - $configFile = 'Koha.ini'; - } - $configFilePath = ConfigReader::getConfigPath($configFile); - if (!file_exists($configFilePath)) { - throw new ILSException( - 'Cannot access config file - ' . $configFilePath - ); + if (empty($this->config)) { + throw new ILSException('Configuration needs to be set.'); } - $configArray = parse_ini_file($configFilePath, true); //Connect to MySQL $this->db = new PDO( - 'mysql:host=' . $configArray['Catalog']['host'] . - ';port=' . $configArray['Catalog']['port'] . - ';dbname=' . $configArray['Catalog']['database'], - $configArray['Catalog']['username'], - $configArray['Catalog']['password'] + 'mysql:host=' . $this->config['Catalog']['host'] . + ';port=' . $this->config['Catalog']['port'] . + ';dbname=' . $this->config['Catalog']['database'], + $this->config['Catalog']['username'], + $this->config['Catalog']['password'] ); // Throw PDOExceptions if something goes wrong $this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); @@ -81,11 +77,11 @@ class Koha implements DriverInterface $this->db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); //Storing the base URL of ILS - $this->ilsBaseUrl = $configArray['Catalog']['url']; + $this->ilsBaseUrl = $this->config['Catalog']['url']; // Location codes are defined in 'Koha.ini' file according to current // version (3.02) - $this->locCodes = $configArray['Location_Codes']; + $this->locCodes = $this->config['Location_Codes']; } /** diff --git a/module/VuFind/src/VuFind/ILS/Driver/NewGenLib.php b/module/VuFind/src/VuFind/ILS/Driver/NewGenLib.php index 82375cb4bc2..3822b51e671 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/NewGenLib.php +++ b/module/VuFind/src/VuFind/ILS/Driver/NewGenLib.php @@ -38,30 +38,25 @@ use PDO, PDOException, VuFind\Config\Reader as ConfigReader, * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @link http://vufind.org/wiki/building_an_ils_driver Wiki */ -class NewGenLib implements DriverInterface +class NewGenLib extends AbstractBase { protected $db; protected $dbName; - protected $config; /** - * Constructor + * Initialize the driver. * - * @param string $configFile The location of an alternative config file + * Validate configuration and perform all resource-intensive tasks needed to + * make the driver active. + * + * @throws ILSException + * @return void */ - public function __construct($configFile = false) + public function init() { - // Load configuration file: - if (!$configFile) { - $configFile = 'NewGenLib.ini'; - } - $configFilePath = ConfigReader::getConfigPath($configFile); - if (!file_exists($configFilePath)) { - throw new ILSException( - 'Cannot access config file - ' . $configFilePath - ); + if (empty($this->config)) { + throw new ILSException('Configuration needs to be set.'); } - $this->config = parse_ini_file($configFilePath, true); // Define Database Name $this->dbName = $this->config['Catalog']['database']; diff --git a/module/VuFind/src/VuFind/ILS/Driver/NoILS.php b/module/VuFind/src/VuFind/ILS/Driver/NoILS.php index d65ce4fc710..0df0eaabe50 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/NoILS.php +++ b/module/VuFind/src/VuFind/ILS/Driver/NoILS.php @@ -40,25 +40,20 @@ use VuFind\Config\Reader as ConfigReader, VuFind\Exception\ILS as ILSException, * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @link http://vufind.org/wiki/building_an_ils_driver Wiki */ -class NoILS implements DriverInterface +class NoILS extends AbstractBase { - protected $config; - /** - * Constructor + * Initialize the driver. + * + * Validate configuration and perform all resource-intensive tasks needed to + * make the driver active. * - * @param string $configFile The location of an alternative config file + * @throws ILSException + * @return void */ - public function __construct($configFile = 'NoILS.ini') + public function init() { - // Load Configuration - $configFilePath = ConfigReader::getConfigPath($configFile); - if (!file_exists($configFilePath)) { - throw new ILSException( - 'Cannot access config file - ' . $configFilePath - ); - } - $this->config = parse_ini_file($configFilePath, true); + // No special processing needed here. } /** diff --git a/module/VuFind/src/VuFind/ILS/Driver/PICA.php b/module/VuFind/src/VuFind/ILS/Driver/PICA.php index 4be10b4dcaa..00776b7bb8a 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/PICA.php +++ b/module/VuFind/src/VuFind/ILS/Driver/PICA.php @@ -56,30 +56,22 @@ class PICA extends DAIA protected $dbsid; /** - * Constructor + * Initialize the driver. * - * @param string $configFile The location of an alternative config file + * Validate configuration and perform all resource-intensive tasks needed to + * make the driver active. + * + * @throws ILSException + * @return void */ - public function __construct($configFile = false) + public function init() { - parent::__construct(); // do not pass $configFile to parent - - // Load configuration file: - if (!$configFile) { - $configFile = 'PICA.ini'; - } - $configFilePath = ConfigReader::getConfigPath($configFile); - if (!file_exists($configFilePath)) { - throw new ILSException( - 'Cannot access config file - ' . $configFilePath - ); - } - $configArray = parse_ini_file($configFilePath, true); + parent::init(); - $this->catalogHost = $configArray['Catalog']['Host']; - $this->renewalsScript = $configArray['Catalog']['renewalsScript']; - $this->dbsid = isset($configArray['Catalog']['DB']) - ? $configArray['Catalog']['DB'] : 1; + $this->catalogHost = $this->config['Catalog']['Host']; + $this->renewalsScript = $this->config['Catalog']['renewalsScript']; + $this->dbsid = isset($this->config['Catalog']['DB']) + ? $this->config['Catalog']['DB'] : 1; } // public functions implemented to satisfy Driver Interface diff --git a/module/VuFind/src/VuFind/ILS/Driver/Sample.php b/module/VuFind/src/VuFind/ILS/Driver/Sample.php index ddeb1db9c7f..1375814e8cc 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/Sample.php +++ b/module/VuFind/src/VuFind/ILS/Driver/Sample.php @@ -38,14 +38,18 @@ namespace VuFind\ILS\Driver; * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @link http://vufind.org/wiki/building_an_ils_driver Wiki */ -class Sample implements DriverInterface +class Sample extends AbstractBase { /** - * Constructor + * Initialize the driver. * - * @param string $configFile The location of an alternative config file + * Validate configuration and perform all resource-intensive tasks needed to + * make the driver active. + * + * @throws ILSException + * @return void */ - public function __construct($configFile = false) + public function init() { // Sample driver doesn't care about configuration. } diff --git a/module/VuFind/src/VuFind/ILS/Driver/Symphony.php b/module/VuFind/src/VuFind/ILS/Driver/Symphony.php index 04156419547..50c1af041ea 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/Symphony.php +++ b/module/VuFind/src/VuFind/ILS/Driver/Symphony.php @@ -27,7 +27,7 @@ * @link http://vufind.org/wiki/building_an_ils_driver Wiki */ namespace VuFind\ILS\Driver; -use SoapFault, VuFind\Cache\Manager as CacheManager, +use SoapClient, SoapFault, VuFind\Cache\Manager as CacheManager, VuFind\Config\Reader as ConfigReader, VuFind\Exception\ILS as ILSException; /** @@ -41,28 +41,22 @@ use SoapFault, VuFind\Cache\Manager as CacheManager, * @link http://vufind.org/wiki/building_an_ils_driver Wiki */ -class Symphony implements DriverInterface +class Symphony extends AbstractBase { - protected $config; protected $policyCache = false; protected $policies; /** - * Constructor + * Initialize the driver. * - * @param string $configFile The location of an alternative config file + * Validate configuration and perform all resource-intensive tasks needed to + * make the driver active. + * + * @throws ILSException + * @return void */ - public function __construct($configFile = 'Symphony.ini') + public function init() { - // Find and load the configuration file if it exists. - $configFilePath = ConfigReader::getConfigPath($configFile); - if (file_exists($configFilePath)) { - $this->config = parse_ini_file($configFilePath, true); - if (!is_array($this->config)) { - throw new ILSException('Could not parse config file!'); - } - } - // Merge in defaults. $this->config += array( 'WebServices' => array(), diff --git a/module/VuFind/src/VuFind/ILS/Driver/Unicorn.php b/module/VuFind/src/VuFind/ILS/Driver/Unicorn.php index b9c63a6ca0d..63bd84074af 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/Unicorn.php +++ b/module/VuFind/src/VuFind/ILS/Driver/Unicorn.php @@ -43,7 +43,7 @@ use VuFind\Config\Reader as ConfigReader, VuFind\Exception\ILS as ILSException, * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @link http://code.google.com/p/vufind-unicorn/ vufind-unicorn project **/ -class Unicorn implements DriverInterface +class Unicorn extends AbstractBase { protected $host; protected $port; @@ -51,38 +51,33 @@ class Unicorn implements DriverInterface protected $url; protected $db; - protected $ilsConfigArray; /** - * Constructor + * Initialize the driver. * - * @param string $configFile The location of an alternative config file + * Validate configuration and perform all resource-intensive tasks needed to + * make the driver active. + * + * @throws ILSException + * @return void */ - public function __construct($configFile = false) + public function init() { - // Load configuration file: - if (!$configFile) { - $configFile = 'Unicorn.ini'; - } - $configFilePath = ConfigReader::getConfigPath($configFile); - if (!file_exists($configFilePath)) { - throw new ILSException( - 'Cannot access config file - ' . $configFilePath - ); + if (empty($this->config)) { + throw new ILSException('Configuration needs to be set.'); } - $this->ilsConfigArray = parse_ini_file($configFilePath, true); // allow user to specify the full url to the Sirsi side perl script - $this->url = $this->ilsConfigArray['Catalog']['url']; + $this->url = $this->config['Catalog']['url']; // host/port/search_prog kept for backward compatibility - if (isset($this->ilsConfigArray['Catalog']['host']) - && isset($this->ilsConfigArray['Catalog']['port']) - && isset($this->ilsConfigArray['Catalog']['search_prog']) + if (isset($this->config['Catalog']['host']) + && isset($this->config['Catalog']['port']) + && isset($this->config['Catalog']['search_prog']) ) { - $this->host = $this->ilsConfigArray['Catalog']['host']; - $this->port = $this->ilsConfigArray['Catalog']['port']; - $this->search_prog = $this->ilsConfigArray['Catalog']['search_prog']; + $this->host = $this->config['Catalog']['host']; + $this->port = $this->config['Catalog']['port']; + $this->search_prog = $this->config['Catalog']['search_prog']; } $this->db = ConnectionManager::connectToIndex(); @@ -98,8 +93,8 @@ class Unicorn implements DriverInterface */ public function getConfig($function) { - if (isset($this->ilsConfigArray[$function]) ) { - $functionConfig = $this->ilsConfigArray[$function]; + if (isset($this->config[$function]) ) { + $functionConfig = $this->config[$function]; } else { $functionConfig = false; } @@ -161,7 +156,7 @@ class Unicorn implements DriverInterface if ($patron && isset($patron['library'])) { return $patron['library']; } - return $this->ilsConfigArray['Holds']['defaultPickupLocation']; + return $this->config['Holds']['defaultPickupLocation']; } /** @@ -224,7 +219,7 @@ class Unicorn implements DriverInterface } else { $results[$chargeKey]['success'] = false; $results[$chargeKey]['sysMessage'] - = $this->ilsConfigArray['ApiMessages'][$status]; + = $this->config['ApiMessages'][$status]; } } preg_match('/\^CI([^\^]+)\^/', $result, $matches); @@ -387,7 +382,7 @@ class Unicorn implements DriverInterface $expire = $holdDetails['requiredBy']; $formatDate = new \VuFind\Date\Converter(); $expire = $formatDate->convertFromDisplayDate( - $this->ilsConfigArray['Catalog']['server_date_format'], + $this->config['Catalog']['server_date_format'], $expire ); @@ -422,7 +417,7 @@ class Unicorn implements DriverInterface } else { return array( 'success' => false, - 'sysMessage' => $this->ilsConfigArray['ApiMessages'][$status]); + 'sysMessage' => $this->config['ApiMessages'][$status]); } } @@ -560,7 +555,7 @@ class Unicorn implements DriverInterface // the amount and balance are in cents, so we need to turn them into // dollars if configured - if (!$this->ilsConfigArray['Catalog']['leaveFinesAmountsInCents']) { + if (!$this->config['Catalog']['leaveFinesAmountsInCents']) { $amount = (floatval($amount) / 100.00); $balance = (floatval($balance) / 100.00); } @@ -960,7 +955,7 @@ class Unicorn implements DriverInterface //query sirsi // isset($lib) // ? $params = array('query' => 'newItems', - // 'lib' => array_search($lib, $ilsConfigArray['Libraries'])) + // 'lib' => array_search($lib, $config['Libraries'])) // : $params = array('query' => 'newItems'); $params = array('query' => 'newitems', 'lib' => 'PPL'); $response = $this->querySirsi($params); @@ -1041,16 +1036,16 @@ class Unicorn implements DriverInterface // even though item is NOT checked out, it still may not be "Available" // the following are the special cases - if (isset($this->ilsConfigArray['UnavailableItemTypes']) - && isset($this->ilsConfigArray['UnavailableItemTypes'][$item_type]) + if (isset($this->config['UnavailableItemTypes']) + && isset($this->config['UnavailableItemTypes'][$item_type]) ) { $availability = 0; - $status = $this->ilsConfigArray['UnavailableItemTypes'][$item_type]; - } else if (isset($this->ilsConfigArray['UnavailableLocations']) - && isset($this->ilsConfigArray['UnavailableLocations'][$currLocCode]) + $status = $this->config['UnavailableItemTypes'][$item_type]; + } else if (isset($this->config['UnavailableLocations']) + && isset($this->config['UnavailableLocations'][$currLocCode]) ) { $availability = 0; - $status= $this->ilsConfigArray['UnavailableLocations'][$currLocCode]; + $status= $this->config['UnavailableLocations'][$currLocCode]; } $item = array ( @@ -1095,10 +1090,10 @@ class Unicorn implements DriverInterface */ protected function mapLocation($code) { - if (isset($this->ilsConfigArray['Locations']) - && isset($this->ilsConfigArray['Locations'][$code]) + if (isset($this->config['Locations']) + && isset($this->config['Locations'][$code]) ) { - return $this->ilsConfigArray['Locations'][$code]; + return $this->config['Locations'][$code]; } return $code; } @@ -1113,10 +1108,10 @@ class Unicorn implements DriverInterface */ protected function mapLibrary($code) { - if (isset($this->ilsConfigArray['Libraries']) - && isset($this->ilsConfigArray['Libraries'][$code]) + if (isset($this->config['Libraries']) + && isset($this->config['Libraries'][$code]) ) { - return $this->ilsConfigArray['Libraries'][$code]; + return $this->config['Libraries'][$code]; } return $code; } diff --git a/module/VuFind/src/VuFind/ILS/Driver/Virtua.php b/module/VuFind/src/VuFind/ILS/Driver/Virtua.php index 40edea8b0d6..d4f01500a8b 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/Virtua.php +++ b/module/VuFind/src/VuFind/ILS/Driver/Virtua.php @@ -38,29 +38,24 @@ use VuFind\Config\Reader as ConfigReader, VuFind\Exception\ILS as ILSException, * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @link http://vufind.org/wiki/building_an_ils_driver Wiki */ -class Virtua implements DriverInterface +class Virtua extends AbstractBase { protected $db; - protected $config; /** - * Constructor, establish a DB connection + * Initialize the driver. * - * @param string $configFile The location of an alternative config file + * Validate configuration and perform all resource-intensive tasks needed to + * make the driver active. + * + * @throws ILSException + * @return void */ - public function __construct($configFile = false) + public function init() { - // Load configuration file: - if (!$configFile) { - $configFile = 'Virtua.ini'; - } - $configFilePath = ConfigReader::getConfigPath($configFile); - if (!file_exists($configFilePath)) { - throw new ILSException( - 'Cannot access config file - ' . $configFilePath - ); + if (empty($this->config)) { + throw new ILSException('Configuration needs to be set.'); } - $this->config = parse_ini_file($configFilePath, true); // Define Database Name $tns = '(DESCRIPTION=' . diff --git a/module/VuFind/src/VuFind/ILS/Driver/Voyager.php b/module/VuFind/src/VuFind/ILS/Driver/Voyager.php index 83353dc904b..d94d171b627 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/Voyager.php +++ b/module/VuFind/src/VuFind/ILS/Driver/Voyager.php @@ -42,32 +42,27 @@ use File_MARC, PDO, PDOException, VuFind\Config\Reader as ConfigReader, * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @link http://vufind.org/wiki/building_an_ils_driver Wiki */ -class Voyager implements DriverInterface +class Voyager extends AbstractBase { protected $db; protected $dbName; - protected $config; protected $statusRankings = false; // used by pickStatus() method protected $dateFormat; /** - * Constructor + * Initialize the driver. * - * @param string $configFile The location of an alternative config file + * Validate configuration and perform all resource-intensive tasks needed to + * make the driver active. + * + * @throws ILSException + * @return void */ - public function __construct($configFile = false) + public function init() { - // Load configuration file: - if (!$configFile) { - $configFile = 'Voyager.ini'; - } - $configFilePath = ConfigReader::getConfigPath($configFile); - if (!file_exists($configFilePath)) { - throw new ILSException( - 'Cannot access config file - ' . $configFilePath - ); + if (empty($this->config)) { + throw new ILSException('Configuration needs to be set.'); } - $this->config = parse_ini_file($configFilePath, true); // Set up object for formatting dates and times: $this->dateFormat = new DateConverter(); diff --git a/module/VuFind/src/VuFind/ILS/Driver/VoyagerRestful.php b/module/VuFind/src/VuFind/ILS/Driver/VoyagerRestful.php index 267671e6f0f..e420e666f0d 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/VoyagerRestful.php +++ b/module/VuFind/src/VuFind/ILS/Driver/VoyagerRestful.php @@ -59,15 +59,17 @@ class VoyagerRestful extends Voyager protected $checkRenewalsUpFront; /** - * Constructor + * Initialize the driver. * - * @param string $configFile Name of configuration file to load (relative to - * web/conf folder; defaults to VoyagerRestful.ini). + * Validate configuration and perform all resource-intensive tasks needed to + * make the driver active. + * + * @throws ILSException + * @return void */ - public function __construct($configFile = 'VoyagerRestful.ini') + public function init() { - // Call the parent's constructor... - parent::__construct($configFile); + parent::init(); // Define Voyager Restful Settings $this->ws_host = $this->config['WebServices']['host']; diff --git a/module/VuFind/src/VuFind/ILS/Driver/XCNCIP.php b/module/VuFind/src/VuFind/ILS/Driver/XCNCIP.php index e51aba7f042..ac200667b24 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/XCNCIP.php +++ b/module/VuFind/src/VuFind/ILS/Driver/XCNCIP.php @@ -38,33 +38,22 @@ use VuFind\Config\Reader as ConfigReader, VuFind\Exception\ILS as ILSException, * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @link http://vufind.org/wiki/building_an_ils_driver Wiki */ -class XCNCIP implements DriverInterface +class XCNCIP extends AbstractBase { /** - * Values loaded from XCNCIP.ini. + * Initialize the driver. * - * @var array - */ - protected $config; - - /** - * Constructor + * Validate configuration and perform all resource-intensive tasks needed to + * make the driver active. * - * @param string $configFile The location of an alternative config file + * @throws ILSException + * @return void */ - public function __construct($configFile = false) + public function init() { - // Load configuration file: - if (!$configFile) { - $configFile = 'XCNCIP.ini'; - } - $configFilePath = ConfigReader::getConfigPath($configFile); - if (!file_exists($configFilePath)) { - throw new ILSException( - 'Cannot access config file - ' . $configFilePath - ); + if (empty($this->config)) { + throw new ILSException('Configuration needs to be set.'); } - $this->config = parse_ini_file($configFilePath, true); } /** diff --git a/module/VuFind/src/VuFind/ILS/Driver/XCNCIP2.php b/module/VuFind/src/VuFind/ILS/Driver/XCNCIP2.php index a4dbae47e5e..9eab35a6ee3 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/XCNCIP2.php +++ b/module/VuFind/src/VuFind/ILS/Driver/XCNCIP2.php @@ -38,33 +38,22 @@ use VuFind\Config\Reader as ConfigReader, VuFind\Exception\ILS as ILSException, * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @link http://vufind.org/wiki/building_an_ils_driver Wiki */ -class XCNCIP2 implements DriverInterface +class XCNCIP2 extends AbstractBase { /** - * Values loaded from XCNCIP2.ini. + * Initialize the driver. * - * @var array - */ - protected $config; - - /** - * Constructor + * Validate configuration and perform all resource-intensive tasks needed to + * make the driver active. * - * @param string $configFile The location of an alternative config file + * @throws ILSException + * @return void */ - public function __construct($configFile = false) + public function init() { - // Load configuration file: - if (!$configFile) { - $configFile = 'XCNCIP2.ini'; - } - $configFilePath = ConfigReader::getConfigPath($configFile); - if (!file_exists($configFilePath)) { - throw new ILSException( - 'Cannot access config file - ' . $configFilePath - ); + if (empty($this->config)) { + throw new ILSException('Configuration needs to be set.'); } - $this->config = parse_ini_file($configFilePath, true); } /** diff --git a/module/VuFind/tests/ILS/Driver/AlephTest.php b/module/VuFind/tests/ILS/Driver/AlephTest.php new file mode 100644 index 00000000000..b7e512f2e81 --- /dev/null +++ b/module/VuFind/tests/ILS/Driver/AlephTest.php @@ -0,0 +1,62 @@ +<?php +/** + * ILS driver test + * + * PHP version 5 + * + * Copyright (C) Villanova University 2011. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @category VuFind2 + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://www.vufind.org Main Page + */ +namespace VuFind\Tests\ILS\Driver; +use VuFind\ILS\Driver\Aleph; + +/** + * ILS driver test + * + * @category VuFind2 + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://www.vufind.org Main Page + */ +class AlephTest extends \VuFind\Tests\TestCase +{ + protected $driver; + + /** + * Constructor + */ + public function __construct() + { + $this->driver = new Aleph(); + } + + /** + * Test that driver complains about missing configuration. + * + * @return void + */ + public function testMissingConfiguration() + { + $this->setExpectedException('VuFind\Exception\ILS'); + $this->driver->init(); + } +} \ No newline at end of file diff --git a/module/VuFind/tests/ILS/Driver/AmicusTest.php b/module/VuFind/tests/ILS/Driver/AmicusTest.php new file mode 100644 index 00000000000..e009fc4bfea --- /dev/null +++ b/module/VuFind/tests/ILS/Driver/AmicusTest.php @@ -0,0 +1,62 @@ +<?php +/** + * ILS driver test + * + * PHP version 5 + * + * Copyright (C) Villanova University 2011. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @category VuFind2 + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://www.vufind.org Main Page + */ +namespace VuFind\Tests\ILS\Driver; +use VuFind\ILS\Driver\Amicus; + +/** + * ILS driver test + * + * @category VuFind2 + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://www.vufind.org Main Page + */ +class AmicusTest extends \VuFind\Tests\TestCase +{ + protected $driver; + + /** + * Constructor + */ + public function __construct() + { + $this->driver = new Amicus(); + } + + /** + * Test that driver complains about missing configuration. + * + * @return void + */ + public function testMissingConfiguration() + { + $this->setExpectedException('VuFind\Exception\ILS'); + $this->driver->init(); + } +} \ No newline at end of file diff --git a/module/VuFind/tests/ILS/Driver/DAIATest.php b/module/VuFind/tests/ILS/Driver/DAIATest.php new file mode 100644 index 00000000000..9bb31a48365 --- /dev/null +++ b/module/VuFind/tests/ILS/Driver/DAIATest.php @@ -0,0 +1,62 @@ +<?php +/** + * ILS driver test + * + * PHP version 5 + * + * Copyright (C) Villanova University 2011. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @category VuFind2 + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://www.vufind.org Main Page + */ +namespace VuFind\Tests\ILS\Driver; +use VuFind\ILS\Driver\DAIA; + +/** + * ILS driver test + * + * @category VuFind2 + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://www.vufind.org Main Page + */ +class DAIATest extends \VuFind\Tests\TestCase +{ + protected $driver; + + /** + * Constructor + */ + public function __construct() + { + $this->driver = new DAIA(); + } + + /** + * Test that driver complains about missing configuration. + * + * @return void + */ + public function testMissingConfiguration() + { + $this->setExpectedException('VuFind\Exception\ILS'); + $this->driver->init(); + } +} \ No newline at end of file diff --git a/module/VuFind/tests/ILS/Driver/DemoTest.php b/module/VuFind/tests/ILS/Driver/DemoTest.php new file mode 100644 index 00000000000..40b2cee0227 --- /dev/null +++ b/module/VuFind/tests/ILS/Driver/DemoTest.php @@ -0,0 +1,63 @@ +<?php +/** + * ILS driver test + * + * PHP version 5 + * + * Copyright (C) Villanova University 2011. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @category VuFind2 + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://www.vufind.org Main Page + */ +namespace VuFind\Tests\ILS\Driver; +use VuFind\ILS\Driver\Demo; + +/** + * ILS driver test + * + * @category VuFind2 + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://www.vufind.org Main Page + */ +class DemoTest extends \VuFind\Tests\TestCase +{ + protected $driver; + + /** + * Constructor + */ + public function __construct() + { + $this->driver = new Demo(); + $this->driver->init(); + } + + /** + * Test that patron login method always returns a fake user. + * + * @return void + */ + public function testPatronLogin() + { + $patron = $this->driver->patronLogin('foo', 'bar'); + $this->assertTrue(isset($patron['id'])); + } +} \ No newline at end of file diff --git a/module/VuFind/tests/ILS/Driver/EvergreenTest.php b/module/VuFind/tests/ILS/Driver/EvergreenTest.php new file mode 100644 index 00000000000..53e3ac895d7 --- /dev/null +++ b/module/VuFind/tests/ILS/Driver/EvergreenTest.php @@ -0,0 +1,62 @@ +<?php +/** + * ILS driver test + * + * PHP version 5 + * + * Copyright (C) Villanova University 2011. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @category VuFind2 + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://www.vufind.org Main Page + */ +namespace VuFind\Tests\ILS\Driver; +use VuFind\ILS\Driver\Evergreen; + +/** + * ILS driver test + * + * @category VuFind2 + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://www.vufind.org Main Page + */ +class EvergreenTest extends \VuFind\Tests\TestCase +{ + protected $driver; + + /** + * Constructor + */ + public function __construct() + { + $this->driver = new Evergreen(); + } + + /** + * Test that driver complains about missing configuration. + * + * @return void + */ + public function testMissingConfiguration() + { + $this->setExpectedException('VuFind\Exception\ILS'); + $this->driver->init(); + } +} \ No newline at end of file diff --git a/module/VuFind/tests/ILS/Driver/HorizonTest.php b/module/VuFind/tests/ILS/Driver/HorizonTest.php new file mode 100644 index 00000000000..6f6b15bf174 --- /dev/null +++ b/module/VuFind/tests/ILS/Driver/HorizonTest.php @@ -0,0 +1,62 @@ +<?php +/** + * ILS driver test + * + * PHP version 5 + * + * Copyright (C) Villanova University 2011. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @category VuFind2 + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://www.vufind.org Main Page + */ +namespace VuFind\Tests\ILS\Driver; +use VuFind\ILS\Driver\Horizon; + +/** + * ILS driver test + * + * @category VuFind2 + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://www.vufind.org Main Page + */ +class HorizonTest extends \VuFind\Tests\TestCase +{ + protected $driver; + + /** + * Constructor + */ + public function __construct() + { + $this->driver = new Horizon(); + } + + /** + * Test that driver complains about missing configuration. + * + * @return void + */ + public function testMissingConfiguration() + { + $this->setExpectedException('VuFind\Exception\ILS'); + $this->driver->init(); + } +} \ No newline at end of file diff --git a/module/VuFind/tests/ILS/Driver/HorizonXMLAPITest.php b/module/VuFind/tests/ILS/Driver/HorizonXMLAPITest.php new file mode 100644 index 00000000000..dc26ae84185 --- /dev/null +++ b/module/VuFind/tests/ILS/Driver/HorizonXMLAPITest.php @@ -0,0 +1,62 @@ +<?php +/** + * ILS driver test + * + * PHP version 5 + * + * Copyright (C) Villanova University 2011. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @category VuFind2 + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://www.vufind.org Main Page + */ +namespace VuFind\Tests\ILS\Driver; +use VuFind\ILS\Driver\HorizonXMLAPI; + +/** + * ILS driver test + * + * @category VuFind2 + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://www.vufind.org Main Page + */ +class HorizonXMLAPITest extends \VuFind\Tests\TestCase +{ + protected $driver; + + /** + * Constructor + */ + public function __construct() + { + $this->driver = new HorizonXMLAPI(); + } + + /** + * Test that driver complains about missing configuration. + * + * @return void + */ + public function testMissingConfiguration() + { + $this->setExpectedException('VuFind\Exception\ILS'); + $this->driver->init(); + } +} \ No newline at end of file diff --git a/module/VuFind/tests/ILS/Driver/InnovativeTest.php b/module/VuFind/tests/ILS/Driver/InnovativeTest.php new file mode 100644 index 00000000000..93150045585 --- /dev/null +++ b/module/VuFind/tests/ILS/Driver/InnovativeTest.php @@ -0,0 +1,62 @@ +<?php +/** + * ILS driver test + * + * PHP version 5 + * + * Copyright (C) Villanova University 2011. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @category VuFind2 + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://www.vufind.org Main Page + */ +namespace VuFind\Tests\ILS\Driver; +use VuFind\ILS\Driver\Innovative; + +/** + * ILS driver test + * + * @category VuFind2 + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://www.vufind.org Main Page + */ +class InnovativeTest extends \VuFind\Tests\TestCase +{ + protected $driver; + + /** + * Constructor + */ + public function __construct() + { + $this->driver = new Innovative(); + } + + /** + * Test that driver complains about missing configuration. + * + * @return void + */ + public function testMissingConfiguration() + { + $this->setExpectedException('VuFind\Exception\ILS'); + $this->driver->init(); + } +} \ No newline at end of file diff --git a/module/VuFind/tests/ILS/Driver/KohaTest.php b/module/VuFind/tests/ILS/Driver/KohaTest.php new file mode 100644 index 00000000000..b056ce9e255 --- /dev/null +++ b/module/VuFind/tests/ILS/Driver/KohaTest.php @@ -0,0 +1,62 @@ +<?php +/** + * ILS driver test + * + * PHP version 5 + * + * Copyright (C) Villanova University 2011. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @category VuFind2 + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://www.vufind.org Main Page + */ +namespace VuFind\Tests\ILS\Driver; +use VuFind\ILS\Driver\Koha; + +/** + * ILS driver test + * + * @category VuFind2 + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://www.vufind.org Main Page + */ +class KohaTest extends \VuFind\Tests\TestCase +{ + protected $driver; + + /** + * Constructor + */ + public function __construct() + { + $this->driver = new Koha(); + } + + /** + * Test that driver complains about missing configuration. + * + * @return void + */ + public function testMissingConfiguration() + { + $this->setExpectedException('VuFind\Exception\ILS'); + $this->driver->init(); + } +} \ No newline at end of file diff --git a/module/VuFind/tests/ILS/Driver/NewGenLibTest.php b/module/VuFind/tests/ILS/Driver/NewGenLibTest.php new file mode 100644 index 00000000000..297f2a7c54b --- /dev/null +++ b/module/VuFind/tests/ILS/Driver/NewGenLibTest.php @@ -0,0 +1,62 @@ +<?php +/** + * ILS driver test + * + * PHP version 5 + * + * Copyright (C) Villanova University 2011. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @category VuFind2 + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://www.vufind.org Main Page + */ +namespace VuFind\Tests\ILS\Driver; +use VuFind\ILS\Driver\NewGenLib; + +/** + * ILS driver test + * + * @category VuFind2 + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://www.vufind.org Main Page + */ +class NewGenLibTest extends \VuFind\Tests\TestCase +{ + protected $driver; + + /** + * Constructor + */ + public function __construct() + { + $this->driver = new NewGenLib(); + } + + /** + * Test that driver complains about missing configuration. + * + * @return void + */ + public function testMissingConfiguration() + { + $this->setExpectedException('VuFind\Exception\ILS'); + $this->driver->init(); + } +} \ No newline at end of file diff --git a/module/VuFind/tests/ILS/Driver/NoILSTest.php b/module/VuFind/tests/ILS/Driver/NoILSTest.php new file mode 100644 index 00000000000..318e252b39b --- /dev/null +++ b/module/VuFind/tests/ILS/Driver/NoILSTest.php @@ -0,0 +1,62 @@ +<?php +/** + * ILS driver test + * + * PHP version 5 + * + * Copyright (C) Villanova University 2011. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @category VuFind2 + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://www.vufind.org Main Page + */ +namespace VuFind\Tests\ILS\Driver; +use VuFind\ILS\Driver\NoILS; + +/** + * ILS driver test + * + * @category VuFind2 + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://www.vufind.org Main Page + */ +class NoILSTest extends \VuFind\Tests\TestCase +{ + protected $driver; + + /** + * Constructor + */ + public function __construct() + { + $this->driver = new NoILS(); + $this->driver->init(); + } + + /** + * Test that driver defaults to 'ils-offline' mode when no config is provided. + * + * @return void + */ + public function testDefaultOfflineMode() + { + $this->assertEquals('ils-offline', $this->driver->getOfflineMode()); + } +} \ No newline at end of file diff --git a/module/VuFind/tests/ILS/Driver/PICATest.php b/module/VuFind/tests/ILS/Driver/PICATest.php new file mode 100644 index 00000000000..6d65c92c548 --- /dev/null +++ b/module/VuFind/tests/ILS/Driver/PICATest.php @@ -0,0 +1,62 @@ +<?php +/** + * ILS driver test + * + * PHP version 5 + * + * Copyright (C) Villanova University 2011. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @category VuFind2 + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://www.vufind.org Main Page + */ +namespace VuFind\Tests\ILS\Driver; +use VuFind\ILS\Driver\PICA; + +/** + * ILS driver test + * + * @category VuFind2 + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://www.vufind.org Main Page + */ +class PICATest extends \VuFind\Tests\TestCase +{ + protected $driver; + + /** + * Constructor + */ + public function __construct() + { + $this->driver = new PICA(); + } + + /** + * Test that driver complains about missing configuration. + * + * @return void + */ + public function testMissingConfiguration() + { + $this->setExpectedException('VuFind\Exception\ILS'); + $this->driver->init(); + } +} \ No newline at end of file diff --git a/module/VuFind/tests/ILS/Driver/SampleTest.php b/module/VuFind/tests/ILS/Driver/SampleTest.php new file mode 100644 index 00000000000..e2ddde207ea --- /dev/null +++ b/module/VuFind/tests/ILS/Driver/SampleTest.php @@ -0,0 +1,63 @@ +<?php +/** + * ILS driver test + * + * PHP version 5 + * + * Copyright (C) Villanova University 2011. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @category VuFind2 + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://www.vufind.org Main Page + */ +namespace VuFind\Tests\ILS\Driver; +use VuFind\ILS\Driver\Sample; + +/** + * ILS driver test + * + * @category VuFind2 + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://www.vufind.org Main Page + */ +class SampleTest extends \VuFind\Tests\TestCase +{ + protected $driver; + + /** + * Constructor + */ + public function __construct() + { + $this->driver = new Sample(); + $this->driver->init(); + } + + /** + * Test that sample driver never returns new items. + * + * @return void + */ + public function testGetNewItems() + { + $new = $this->driver->getNewItems(1, 1, 1); + $this->assertEquals(0, $new['count']); + } +} \ No newline at end of file diff --git a/module/VuFind/tests/ILS/Driver/SymphonyTest.php b/module/VuFind/tests/ILS/Driver/SymphonyTest.php new file mode 100644 index 00000000000..857921a8239 --- /dev/null +++ b/module/VuFind/tests/ILS/Driver/SymphonyTest.php @@ -0,0 +1,66 @@ +<?php +/** + * ILS driver test + * + * PHP version 5 + * + * Copyright (C) Villanova University 2011. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @category VuFind2 + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://www.vufind.org Main Page + */ +namespace VuFind\Tests\ILS\Driver; +use VuFind\ILS\Driver\Symphony; + +/** + * ILS driver test + * + * @category VuFind2 + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://www.vufind.org Main Page + */ +class SymphonyTest extends \VuFind\Tests\TestCase +{ + protected $driver; + + /** + * Constructor + */ + public function __construct() + { + $this->driver = new Symphony(); + } + + /** + * Test that driver complains about invalid base URL configuration. + * + * @return void + */ + public function testBadBaseUrl() + { + $this->driver->setConfig( + array('WebServices' => array('baseURL' => 'invalid')) + ); + $this->driver->init(); + $pickup = @$this->driver->getPickUpLocations(); + $this->assertTrue(empty($pickup)); + } +} \ No newline at end of file diff --git a/module/VuFind/tests/ILS/Driver/UnicornTest.php b/module/VuFind/tests/ILS/Driver/UnicornTest.php new file mode 100644 index 00000000000..fa00efbab87 --- /dev/null +++ b/module/VuFind/tests/ILS/Driver/UnicornTest.php @@ -0,0 +1,62 @@ +<?php +/** + * ILS driver test + * + * PHP version 5 + * + * Copyright (C) Villanova University 2011. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @category VuFind2 + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://www.vufind.org Main Page + */ +namespace VuFind\Tests\ILS\Driver; +use VuFind\ILS\Driver\Unicorn; + +/** + * ILS driver test + * + * @category VuFind2 + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://www.vufind.org Main Page + */ +class UnicornTest extends \VuFind\Tests\TestCase +{ + protected $driver; + + /** + * Constructor + */ + public function __construct() + { + $this->driver = new Unicorn(); + } + + /** + * Test that driver complains about missing configuration. + * + * @return void + */ + public function testMissingConfiguration() + { + $this->setExpectedException('VuFind\Exception\ILS'); + $this->driver->init(); + } +} \ No newline at end of file diff --git a/module/VuFind/tests/ILS/Driver/VirtuaTest.php b/module/VuFind/tests/ILS/Driver/VirtuaTest.php new file mode 100644 index 00000000000..d9939456f89 --- /dev/null +++ b/module/VuFind/tests/ILS/Driver/VirtuaTest.php @@ -0,0 +1,62 @@ +<?php +/** + * ILS driver test + * + * PHP version 5 + * + * Copyright (C) Villanova University 2011. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @category VuFind2 + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://www.vufind.org Main Page + */ +namespace VuFind\Tests\ILS\Driver; +use VuFind\ILS\Driver\Virtua; + +/** + * ILS driver test + * + * @category VuFind2 + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://www.vufind.org Main Page + */ +class VirtuaTest extends \VuFind\Tests\TestCase +{ + protected $driver; + + /** + * Constructor + */ + public function __construct() + { + $this->driver = new Virtua(); + } + + /** + * Test that driver complains about missing configuration. + * + * @return void + */ + public function testMissingConfiguration() + { + $this->setExpectedException('VuFind\Exception\ILS'); + $this->driver->init(); + } +} \ No newline at end of file diff --git a/module/VuFind/tests/ILS/Driver/VoyagerRestfulTest.php b/module/VuFind/tests/ILS/Driver/VoyagerRestfulTest.php new file mode 100644 index 00000000000..c7bee219008 --- /dev/null +++ b/module/VuFind/tests/ILS/Driver/VoyagerRestfulTest.php @@ -0,0 +1,62 @@ +<?php +/** + * ILS driver test + * + * PHP version 5 + * + * Copyright (C) Villanova University 2011. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @category VuFind2 + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://www.vufind.org Main Page + */ +namespace VuFind\Tests\ILS\Driver; +use VuFind\ILS\Driver\VoyagerRestful; + +/** + * ILS driver test + * + * @category VuFind2 + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://www.vufind.org Main Page + */ +class VoyagerRestfulTest extends \VuFind\Tests\TestCase +{ + protected $driver; + + /** + * Constructor + */ + public function __construct() + { + $this->driver = new VoyagerRestful(); + } + + /** + * Test that driver complains about missing configuration. + * + * @return void + */ + public function testMissingConfiguration() + { + $this->setExpectedException('VuFind\Exception\ILS'); + $this->driver->init(); + } +} \ No newline at end of file diff --git a/module/VuFind/tests/ILS/Driver/VoyagerTest.php b/module/VuFind/tests/ILS/Driver/VoyagerTest.php new file mode 100644 index 00000000000..4e78c6fb800 --- /dev/null +++ b/module/VuFind/tests/ILS/Driver/VoyagerTest.php @@ -0,0 +1,62 @@ +<?php +/** + * ILS driver test + * + * PHP version 5 + * + * Copyright (C) Villanova University 2011. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @category VuFind2 + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://www.vufind.org Main Page + */ +namespace VuFind\Tests\ILS\Driver; +use VuFind\ILS\Driver\Voyager; + +/** + * ILS driver test + * + * @category VuFind2 + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://www.vufind.org Main Page + */ +class VoyagerTest extends \VuFind\Tests\TestCase +{ + protected $driver; + + /** + * Constructor + */ + public function __construct() + { + $this->driver = new Voyager(); + } + + /** + * Test that driver complains about missing configuration. + * + * @return void + */ + public function testMissingConfiguration() + { + $this->setExpectedException('VuFind\Exception\ILS'); + $this->driver->init(); + } +} \ No newline at end of file diff --git a/module/VuFind/tests/ILS/Driver/XCNCIP2Test.php b/module/VuFind/tests/ILS/Driver/XCNCIP2Test.php new file mode 100644 index 00000000000..ba543fddf46 --- /dev/null +++ b/module/VuFind/tests/ILS/Driver/XCNCIP2Test.php @@ -0,0 +1,62 @@ +<?php +/** + * ILS driver test + * + * PHP version 5 + * + * Copyright (C) Villanova University 2011. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @category VuFind2 + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://www.vufind.org Main Page + */ +namespace VuFind\Tests\ILS\Driver; +use VuFind\ILS\Driver\XCNCIP2; + +/** + * ILS driver test + * + * @category VuFind2 + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://www.vufind.org Main Page + */ +class XCNCIP2Test extends \VuFind\Tests\TestCase +{ + protected $driver; + + /** + * Constructor + */ + public function __construct() + { + $this->driver = new XCNCIP2(); + } + + /** + * Test that driver complains about missing configuration. + * + * @return void + */ + public function testMissingConfiguration() + { + $this->setExpectedException('VuFind\Exception\ILS'); + $this->driver->init(); + } +} \ No newline at end of file diff --git a/module/VuFind/tests/ILS/Driver/XCNCIPTest.php b/module/VuFind/tests/ILS/Driver/XCNCIPTest.php new file mode 100644 index 00000000000..c0cd0755f80 --- /dev/null +++ b/module/VuFind/tests/ILS/Driver/XCNCIPTest.php @@ -0,0 +1,62 @@ +<?php +/** + * ILS driver test + * + * PHP version 5 + * + * Copyright (C) Villanova University 2011. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @category VuFind2 + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://www.vufind.org Main Page + */ +namespace VuFind\Tests\ILS\Driver; +use VuFind\ILS\Driver\XCNCIP; + +/** + * ILS driver test + * + * @category VuFind2 + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://www.vufind.org Main Page + */ +class XCNCIPTest extends \VuFind\Tests\TestCase +{ + protected $driver; + + /** + * Constructor + */ + public function __construct() + { + $this->driver = new XCNCIP(); + } + + /** + * Test that driver complains about missing configuration. + * + * @return void + */ + public function testMissingConfiguration() + { + $this->setExpectedException('VuFind\Exception\ILS'); + $this->driver->init(); + } +} \ No newline at end of file -- GitLab