diff --git a/module/VuFind/tests/bootstrap.php b/module/VuFind/tests/bootstrap.php index 9002d67593ead9a4cccf68248dca960f592dd7ac..8080bf762bc530d67e1718e4c6c8e0ddca0c8b72 100644 --- a/module/VuFind/tests/bootstrap.php +++ b/module/VuFind/tests/bootstrap.php @@ -39,6 +39,7 @@ if (file_exists('vendor/autoload.php')) { $loader->add('VuFind', __DIR__ . '/../src'); $loader->add('VuFindHttp', __DIR__ . '/../../VuFindHttp/src'); $loader->add('VuFindSearch', __DIR__ . '/../../VuFindSearch/src'); + $loader->add('VuFindTheme', __DIR__ . '/../../VuFindTheme/src'); $loader->register(); } diff --git a/module/VuFind/tests/phpunit.xml b/module/VuFind/tests/phpunit.xml index b9d59fe1032f133eb751b1001cf326578e7aa146..adb9a8286d5054973d42ee80c5f07736b984e3eb 100644 --- a/module/VuFind/tests/phpunit.xml +++ b/module/VuFind/tests/phpunit.xml @@ -6,6 +6,9 @@ <testsuite name="VuFindSearch"> <directory>../../VuFindSearch/tests/unit-tests/src</directory> </testsuite> + <testsuite name="VuFindTheme"> + <directory>../../VuFindTheme/tests/unit-tests/src</directory> + </testsuite> <testsuite name="VuFindUnit"> <directory>unit-tests/src</directory> </testsuite> diff --git a/module/VuFindTheme/tests/unit-tests/bootstrap.php b/module/VuFindTheme/tests/unit-tests/bootstrap.php new file mode 100644 index 0000000000000000000000000000000000000000..45b93e67dc4551b26ff47798739c07cc99f8e166 --- /dev/null +++ b/module/VuFindTheme/tests/unit-tests/bootstrap.php @@ -0,0 +1,22 @@ +<?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( + 'VuFindTheme' => realpath(__DIR__ . '/../../src/VuFindTheme'), + 'VuFindTest' => realpath(__DIR__ . '/src/VuFindTest'), + ), + 'autoregister_zf' => true + ) + ) +); diff --git a/module/VuFindTheme/tests/unit-tests/phpunit.xml b/module/VuFindTheme/tests/unit-tests/phpunit.xml new file mode 100644 index 0000000000000000000000000000000000000000..55ee799fff4729d139d52edbe223da5076b2eb61 --- /dev/null +++ b/module/VuFindTheme/tests/unit-tests/phpunit.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> +<phpunit bootstrap="bootstrap.php" + strict="true"> + <testsuites> + <testsuite name="VuFindTheme"> + <directory>src</directory> + </testsuite> + </testsuites> + <php> + <includePath>../../../../vendor/zendframework/zendframework/library</includePath> + </php> +</phpunit> diff --git a/module/VuFindTheme/tests/unit-tests/src/VuFindTest/ThemeInjectTemplateListenerTest.php b/module/VuFindTheme/tests/unit-tests/src/VuFindTest/ThemeInjectTemplateListenerTest.php new file mode 100644 index 0000000000000000000000000000000000000000..80fede6429079203682390af7ae9b5ee1b7e45b8 --- /dev/null +++ b/module/VuFindTheme/tests/unit-tests/src/VuFindTest/ThemeInjectTemplateListenerTest.php @@ -0,0 +1,67 @@ +<?php +/** + * InjectTemplateListener 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; +use VuFindTheme\InjectTemplateListener; + +/** + * 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 ThemeInjectTemplateListenerTest extends Unit\TestCase +{ + /** + * Test namespace stripping. + * + * @return void + */ + public function testNamespaceStripping() + { + $l = new InjectTemplateListener(); + $this->assertEquals( + '', $this->callMethod($l, 'deriveModuleNamespace', array('dummy')) + ); + } + + /** + * Test camelcase handling. + * + * @return void + */ + public function testCamelCaseToLowerCase() + { + $l = new InjectTemplateListener(); + $this->assertEquals( + 'testcase', $this->callMethod($l, 'inflectName', array('testCase')) + ); + } +} \ No newline at end of file