This class is a transparent base class for Unittest_TestCase and should not be accessed directly.
A version of the stock PHPUnit testcase that includes some extra helpers and default settings[!!] This class, or a class parent, could not be found or loaded. This could be caused by a missing module or other dependancy. The documentation for class may not be complete!
Class declared in MODPATH/unittest/classes/Kohana/Unittest/TestCase.php on line 7.
boolean
$_assert_type_compatabilityWhether we should enable work arounds to make the tests compatible with phpunit 3.4
NULL
Kohana_Unittest_Helpers
$_helpersA set of unittest helpers that are shared between normal / database testcases
NULL
boolean
$backupGlobalsMake sure PHPUnit backs up globals
bool FALSE
array
$environmentDefaultA default set of environment to be applied before each test
array(0)
Asserts that an attribute is of a given type.
string
$expected
required - $expectedstring
$attributeName
required - $attributeNamemixed
$classOrObject
required - $classOrObjectstring
$message
= string(0) "" - $messagepublic static function assertAttributeInstanceOf($expected, $attributeName, $classOrObject, $message = '')
{
if(self::$_assert_type_compatability)
{
return self::assertAttributeType($expected, $attributeName, $classOrObject, $message);
}
return parent::assertAttributeInstanceOf($expected, $attributeName, $classOrObject, $message);
}
Asserts that an attribute is of a given type.
string
$expected
required - $expectedstring
$attributeName
required - $attributeNamemixed
$classOrObject
required - $classOrObjectstring
$message
= string(0) "" - $messagepublic static function assertAttributeInternalType($expected, $attributeName, $classOrObject, $message = '')
{
if(self::$_assert_type_compatability)
{
return self::assertAttributeType($expected, $attributeName, $classOrObject, $message);
}
return parent::assertAttributeInternalType($expected, $attributeName, $classOrObject, $message);
}
Asserts that an attribute is of a given type.
string
$expected
required - $expectedstring
$attributeName
required - $attributeNamemixed
$classOrObject
required - $classOrObjectstring
$message
= string(0) "" - $messagepublic static function assertAttributeNotInstanceOf($expected, $attributeName, $classOrObject, $message = '')
{
if(self::$_assert_type_compatability)
{
return self::assertAttributeNotType($expected, $attributeName, $classOrObject, $message);
}
return parent::assertAttributeNotInstanceOf($expected, $attributeName, $classOrObject, $message);
}
Asserts that an attribute is of a given type.
string
$expected
required - $expectedstring
$attributeName
required - $attributeNamemixed
$classOrObject
required - $classOrObjectstring
$message
= string(0) "" - $messagepublic static function assertAttributeNotInternalType($expected, $attributeName, $classOrObject, $message = '')
{
if(self::$_assert_type_compatability)
{
return self::assertAttributeNotType($expected, $attributeName, $classOrObject, $message);
}
return parent::assertAttributeNotInternalType($expected, $attributeName, $classOrObject, $message);
}
Asserts that a variable is of a given type.
string
$expected
required - $expectedmixed
$actual
required - $actualstring
$message
= string(0) "" - $messagepublic static function assertInstanceOf($expected, $actual, $message = '')
{
if(self::$_assert_type_compatability)
{
return self::assertType($expected, $actual, $message);
}
return parent::assertInstanceOf($expected, $actual, $message);
}
Asserts that a variable is of a given type.
string
$expected
required - $expectedmixed
$actual
required - $actualstring
$message
= string(0) "" - $messagepublic static function assertInternalType($expected, $actual, $message = '')
{
if(self::$_assert_type_compatability)
{
return self::assertType($expected, $actual, $message);
}
return parent::assertInternalType($expected, $actual, $message);
}
Asserts that a variable is not of a given type.
string
$expected
required - $expectedmixed
$actual
required - $actualstring
$message
= string(0) "" - $messagepublic static function assertNotInstanceOf($expected, $actual, $message = '')
{
if(self::$_assert_type_compatability)
{
return self::assertNotType($expected, $actual, $message);
}
return parent::assertNotInstanceOf($expected, $actual, $message);
}
Asserts that a variable is not of a given type.
string
$expected
required - $expectedmixed
$actual
required - $actualstring
$message
= string(0) "" - $messagepublic static function assertNotInternalType($expected, $actual, $message = '')
{
if(self::$_assert_type_compatability)
{
return self::assertNotType($expected, $actual, $message);
}
return parent::assertNotInternalType($expected, $actual, $message);
}
This assertion is the exact opposite of assertTag
Rather than asserting that $matcher results in a match, it asserts that $matcher does not match
NOTE: Overriding this method to remove the deprecation error when tested with PHPUnit 4.2.0+
TODO: this should be removed when phpunit-dom-assertions gets released https://github.com/phpunit/phpunit-dom-assertions
array
$matcher
required - $matcherstring
$actual
required - $actualstring
$message
= string(0) "" - $messagebool
$isHtml
= bool TRUE - $isHtmlpublic static function assertNotTag($matcher, $actual, $message = '', $isHtml = true)
{
//trigger_error(__METHOD__ . ' is deprecated', E_USER_DEPRECATED);
$matched = static::tag_match($matcher, $actual, $message, $isHtml);
static::assertFalse($matched, $message);
}
Evaluate an HTML or XML string and assert its structure and/or contents.
NOTE: Overriding this method to remove the deprecation error when tested with PHPUnit 4.2.0+
TODO: this should be removed when phpunit-dom-assertions gets released https://github.com/phpunit/phpunit-dom-assertions
array
$matcher
required - $matcherstring
$actual
required - $actualstring
$message
= string(0) "" - $messagebool
$isHtml
= bool TRUE - $isHtmlpublic static function assertTag($matcher, $actual, $message = '', $isHtml = true)
{
//trigger_error(__METHOD__ . ' is deprecated', E_USER_DEPRECATED);
$matched = static::tag_match($matcher, $actual, $message, $isHtml);
static::assertTrue($matched, $message);
}
Removes all kohana related cache files in the cache directory
public function cleanCacheDir()
{
return Unittest_Helpers::clean_cache_dir();
}
Helper function that replaces all occurences of '/' with the OS-specific directory separator
string
$path
required - The path to act onstring
public function dirSeparator($path)
{
return Unittest_Helpers::dir_separator($path);
}
Check for internet connectivity
boolean
- Whether an internet connection is availablepublic function hasInternet()
{
return Unittest_Helpers::has_internet();
}
Allows easy setting & backing up of enviroment config
Option types are checked in the following order:
array
$environment
required - List of environment to setpublic function setEnvironment(array $environment)
{
return $this->_helpers->set_environment($environment);
}
Creates a predefined environment using the default environment
Extending classes that have their own setUp() should call parent::setUp()
public function setUp()
{
if(self::$_assert_type_compatability === NULL)
{
if( ! class_exists('PHPUnit_Runner_Version'))
{
require_once 'PHPUnit/Runner/Version.php';
}
self::$_assert_type_compatability = version_compare(PHPUnit_Runner_Version::id(), '3.5.0', '<=');
}
$this->_helpers = new Unittest_Helpers;
$this->setEnvironment($this->environmentDefault);
}
Restores the original environment overriden with setEnvironment()
Extending classes that have their own tearDown() should call parent::tearDown()
public function tearDown()
{
$this->_helpers->restore_environment();
}
Creates classes when they are otherwise not found.
Kodoc::create_class('ThisClassDoesNotExist');
All classes created will extend Kodoc_Missing.
string
$class
required - Class nameboolean
public static function create_class($class)
{
if ( ! class_exists($class))
{
// Create a new missing class
eval("class {$class} extends Kodoc_Missing {}");
}
return TRUE;
}
Helper function to match HTML string tags against certain criteria
TODO: this should be removed when phpunit-dom-assertions gets released https://github.com/phpunit/phpunit-dom-assertions
array
$matcher
required - $matcherstring
$actual
required - $actualstring
$message
= string(0) "" - $messagebool
$isHtml
= bool TRUE - $isHtmlbool
- TRUE if there is a match FALSE otherwiseprotected static function tag_match($matcher, $actual, $message = '', $isHtml = true)
{
$dom = PHPUnit_Util_XML::load($actual, $isHtml);
$tags = PHPUnit_Util_XML::findNodes($dom, $matcher, $isHtml);
return count($tags) > 0 && $tags[0] instanceof DOMNode;
}