Skip to content
Snippets Groups Projects
Commit cb2f08fe authored by Demian Katz's avatar Demian Katz
Browse files

Set up test infrastructure for VuFindConsole module.

parent e730ff56
No related merge requests found
......@@ -37,6 +37,7 @@ if (file_exists('vendor/autoload.php')) {
$loader->add('VuFindTest', __DIR__ . '/unit-tests/src');
$loader->add('VuFindTest', __DIR__ . '/../src');
$loader->add('VuFind', __DIR__ . '/../src');
$loader->add('VuFindConsole', __DIR__ . '/../../VuFindConsole/src');
$loader->add('VuFindHttp', __DIR__ . '/../../VuFindHttp/src');
$loader->add('VuFindSearch', __DIR__ . '/../../VuFindSearch/src');
$loader->add('VuFindTheme', __DIR__ . '/../../VuFindTheme/src');
......
<phpunit bootstrap="./bootstrap.php" backupGlobals="false">
<testsuites>
<testsuite name="VuFindConsole">
<directory>../../VuFindConsole/tests/unit-tests/src</directory>
</testsuite>
<testsuite name="VuFindHttp">
<directory>../../VuFindHttp/tests/unit-tests/src</directory>
</testsuite>
......
<?php
/**
* Search subsystem PHPUnit bootstrap.
*
* @author David Maus <maus@hab.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @copyright Copyright (C) Villanova University 2011
*/
require_once('Zend/Loader/AutoloaderFactory.php');
\Zend\Loader\AutoloaderFactory::factory(
array(
'Zend\Loader\StandardAutoloader' => array(
'namespaces' => array(
'VuFindConsole' => realpath(__DIR__ . '/../../src/VuFindConsole'),
'VuFindTest' => realpath(__DIR__ . '/src/VuFindTest'),
),
'autoregister_zf' => true
)
)
);
<?xml version="1.0" encoding="utf-8"?>
<phpunit bootstrap="bootstrap.php"
strict="true">
<testsuites>
<testsuite name="VuFindConsole">
<directory>src</directory>
</testsuite>
</testsuites>
<php>
<includePath>../../../../vendor/zendframework/zendframework/library</includePath>
</php>
</phpunit>
<?php
/**
* ConsoleRouter Test Class
*
* 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 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://vufind.org/wiki/vufind2:unit_tests Wiki
*/
namespace VuFindTest\Mvc\Router;
use VuFindConsole\Mvc\Router\ConsoleRouter;
/**
* InjectTemplateListener Test Class
*
* @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://vufind.org/wiki/vufind2:unit_tests Wiki
*/
class ConsoleRouterTest extends \PHPUnit_Framework_TestCase
{
/**
* Test routing.
*
* @return void
*/
public function testRoute()
{
$router = ConsoleRouter::factory(array('pwd' => __DIR__));
$request = $this->getMock('Zend\Console\Request', array('getScriptName'));
$request->expects($this->any())->method('getScriptName')
->will($this->returnValue('ConsoleRouterTest.php'));
$result = $router->match($request);
$this->assertEquals($result->getParam('controller'), 'Router');
$this->assertEquals($result->getParam('action'), 'ConsoleRouterTest');
}
/**
* Test addRoute.
*
* @return void
*/
public function testAddRoute()
{
$this->setExpectedException('Exception');
$router = ConsoleRouter::factory();
$router->addRoute('fake', 'fake');
}
/**
* Test addRoutes.
*
* @return void
*/
public function testAddRoutes()
{
$this->setExpectedException('Exception');
$router = ConsoleRouter::factory();
$router->addRoutes(array());
}
/**
* Test removeRoute.
*
* @return void
*/
public function testRemoveRoute()
{
$this->setExpectedException('Exception');
$router = ConsoleRouter::factory();
$router->removeRoute('fake');
}
/**
* Test setRoutes.
*
* @return void
*/
public function testSetRoutes()
{
$this->setExpectedException('Exception');
$router = ConsoleRouter::factory();
$router->setRoutes(array());
}
}
\ 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