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

Merge branch 't/provide-base-testcase-class-1' of git://github.com/dmj/vf2

parents f81629e4 8a20d3c3
No related merge requests found
<?php
/**
* Abstract base class for PHPUnit test cases.
*
* 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 David Maus <maus@hab.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://vufind.org/wiki/unit_tests Wiki
*/
namespace VuFind\Tests;
/**
* Abstract base class for PHPUnit test cases.
*
* @category VuFind2
* @package Tests
* @author David Maus <maus@hab.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://vufind.org/wiki/unit_tests Wiki
*/
abstract class TestCase extends \PHPUnit_Framework_TestCase
{
/**
* Call protected or private method for side-effect and result.
*
* Uses PHP's reflection API in order to modify method accessibility.
*
* @param object|string $object Object or class name
* @param string $method Method name
* @param array $arguments Method arguments
*
* @throws \ReflectionException Method does not exist
*
* @return mixed
*/
protected function callMethod ($object, $method, array $arguments = array())
{
$reflectionMethod = new \ReflectionMethod($object, $method);
$reflectionMethod->setAccessible(true);
return $reflectionMethod->invokeArgs($object, $arguments);
}
/**
* Return protected or private property.
*
* Uses PHP's reflection API in order to modify property accessibility.
*
* @param object|string $object Object or class name
* @param string $property Property name
*
* @throws \ReflectionException Property does not exist
*
* @return mixed
*/
protected function getProperty ($object, $property)
{
$reflectionProperty = new \ReflectionProperty($object, $property);
$reflectionProperty->setAccessible(true);
return $reflectionProperty->getValue($object);
}
/**
* Set protected or private property.
*
* Uses PHP's reflection API in order to modify property accessibility.
*
* @param object|string $object Object or class name
* @param string $property Property name
* @param mixed $value Property value
*
* @throws \ReflectionException Property does not exist
*
* @return void
*/
protected function setProperty ($object, $property, $value)
{
$reflectionProperty = new \ReflectionProperty($object, $property);
$reflectionProperty->setAccessible(true);
return $reflectionProperty->setValue($object, $value);
}
}
\ No newline at end of file
...@@ -38,7 +38,7 @@ use VuFind\Code\ISBN; ...@@ -38,7 +38,7 @@ use VuFind\Code\ISBN;
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://vufind.org/wiki/unit_tests Wiki * @link http://vufind.org/wiki/unit_tests Wiki
*/ */
class ISBNTest extends \PHPUnit_Framework_TestCase class ISBNTest extends \VuFind\Tests\TestCase
{ {
/** /**
* Test Valid ISBN-10. * Test Valid ISBN-10.
......
...@@ -38,7 +38,7 @@ use VuFind\Config\Reader; ...@@ -38,7 +38,7 @@ use VuFind\Config\Reader;
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://vufind.org/wiki/unit_tests Wiki * @link http://vufind.org/wiki/unit_tests Wiki
*/ */
class ReaderTest extends \PHPUnit_Framework_TestCase class ReaderTest extends \VuFind\Tests\TestCase
{ {
/** /**
* Test basic config.ini loading. * Test basic config.ini loading.
......
...@@ -38,7 +38,7 @@ use VuFind\Date\Converter, VuFind\Exception\Date as DateException, ...@@ -38,7 +38,7 @@ use VuFind\Date\Converter, VuFind\Exception\Date as DateException,
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://www.vufind.org Main Page * @link http://www.vufind.org Main Page
*/ */
class ConverterTest extends \PHPUnit_Framework_TestCase class ConverterTest extends \VuFind\Tests\TestCase
{ {
protected $savedDateFormat = null; protected $savedDateFormat = null;
protected $savedTimeFormat = null; protected $savedTimeFormat = null;
......
...@@ -37,7 +37,7 @@ use VuFind\Solr\Utils; ...@@ -37,7 +37,7 @@ use VuFind\Solr\Utils;
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://vufind.org/wiki/unit_tests Wiki * @link http://vufind.org/wiki/unit_tests Wiki
*/ */
class UtilsTest extends \PHPUnit_Framework_TestCase class UtilsTest extends \VuFind\Tests\TestCase
{ {
/** /**
* Test capitalizeBooleans functionality. * Test capitalizeBooleans functionality.
......
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