From 284dd4c8cab56c2645279f85ba21610fc611dd24 Mon Sep 17 00:00:00 2001
From: Demian Katz <demian.katz@villanova.edu>
Date: Tue, 10 Sep 2013 09:07:21 -0400
Subject: [PATCH] Set up test suite for VuFindTheme module.

---
 module/VuFind/tests/bootstrap.php             |  1 +
 module/VuFind/tests/phpunit.xml               |  3 +
 .../tests/unit-tests/bootstrap.php            | 22 ++++++
 .../VuFindTheme/tests/unit-tests/phpunit.xml  | 12 ++++
 .../ThemeInjectTemplateListenerTest.php       | 67 +++++++++++++++++++
 5 files changed, 105 insertions(+)
 create mode 100644 module/VuFindTheme/tests/unit-tests/bootstrap.php
 create mode 100644 module/VuFindTheme/tests/unit-tests/phpunit.xml
 create mode 100644 module/VuFindTheme/tests/unit-tests/src/VuFindTest/ThemeInjectTemplateListenerTest.php

diff --git a/module/VuFind/tests/bootstrap.php b/module/VuFind/tests/bootstrap.php
index 9002d67593e..8080bf762bc 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 b9d59fe1032..adb9a8286d5 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 00000000000..45b93e67dc4
--- /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 00000000000..55ee799fff4
--- /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 00000000000..80fede64290
--- /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
-- 
GitLab