From 11332bc4bf5563cf76a5f21152c6504bd6110dce Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Fri, 5 Dec 2014 14:57:10 -0500 Subject: [PATCH] Stub test for OAI server. --- .../src/VuFindTest/OAI/ServerTest.php | 137 ++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 module/VuFind/tests/unit-tests/src/VuFindTest/OAI/ServerTest.php diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/OAI/ServerTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/OAI/ServerTest.php new file mode 100644 index 00000000000..29d1ef11e5d --- /dev/null +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/OAI/ServerTest.php @@ -0,0 +1,137 @@ +<?php + +/** + * OAI-PMH server unit test. + * + * PHP version 5 + * + * Copyright (C) Villanova University 2010. + * + * 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 Search + * @package Service + * @author David Maus <maus@hab.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://github.com/dmj/vf2-proxy + */ + +namespace VuFindTest\OAI; + +use VuFind\OAI\Server; + +/** + * OAI-PMH server unit test. + * + * PHP version 5 + * + * Copyright (C) Villanova University 2010. + * + * 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 Search + * @package Service + * @author David Maus <maus@hab.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://github.com/dmj/vf2-proxy + */ + +class ServerTest extends \VuFindTest\Unit\TestCase +{ + /** + * Test an empty input. + * + * @return void + */ + public function testEmptyInput() + { + $server = $this->getServer(); + $this->assertTrue(false !== strpos($server->getResponse(), '<error code="badArgument">Missing Verb Argument</error>')); + } + + /** + * Get a server object. + * + * @param array $config Server configuration + * @param string $baseURL Server base URL + * @param array $params Incoming query parameters + * + * @return Server + */ + protected function getServer($config = array(), $baseURL = 'http://foo', + $params = array() + ) { + // Force an email into the configuration if missing; this is required by the + // server. + if (!isset($config['Site']['email'])) { + $config['Site']['email'] = 'fake@example.com'; + } + + return new Server( + $this->getMockResultsManager(), + $this->getMockRecordLoader(), + $this->getMockTableManager(), + new \Zend\Config\Config($config), + $baseURL, + $params + ); + } + + /** + * Get a mock results manager + * + * @return \VuFind\Search\Results\PluginManager + */ + protected function getMockResultsManager() + { + return $this->getMockBuilder('VuFind\Search\Results\PluginManager') + ->disableOriginalConstructor() + ->getMock(); + } + + /** + * Get a mock record loader + * + * @return \VuFind\Record\Loader + */ + protected function getMockRecordLoader() + { + return $this->getMockBuilder('VuFind\Record\Loader') + ->disableOriginalConstructor() + ->getMock(); + } + + /** + * Get a mock table manager + * + * @return \VuFind\Db\Table\PluginManager + */ + protected function getMockTableManager() + { + return $this->getMockBuilder('VuFind\Db\Table\PluginManager') + ->disableOriginalConstructor() + ->getMock(); + } +} \ No newline at end of file -- GitLab