mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-11-09 23:28:42 +00:00
Factor out common DefinitionCache test code to a harness.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1098 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
parent
de23201cbb
commit
95499e34da
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
require_once 'HTMLPurifier/DefinitionCacheHarness.php';
|
||||
require_once 'HTMLPurifier/DefinitionCache/Serializer.php';
|
||||
|
||||
class HTMLPurifier_Definition_SerializerMock extends HTMLPurifier_Definition
|
||||
@ -25,7 +26,7 @@ class HTMLPurifier_Definition_SerializerMock extends HTMLPurifier_Definition
|
||||
|
||||
}
|
||||
|
||||
class HTMLPurifier_DefinitionCache_SerializerTest extends UnitTestCase
|
||||
class HTMLPurifier_DefinitionCache_SerializerTest extends HTMLPurifier_DefinitionCacheHarness
|
||||
{
|
||||
|
||||
function test__SerializerMock_pass() {
|
||||
@ -149,31 +150,6 @@ class HTMLPurifier_DefinitionCache_SerializerTest extends UnitTestCase
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a configuration mock object that returns $values
|
||||
* to a getBatch() call
|
||||
* @param $values Values to return when getBatch is invoked
|
||||
*/
|
||||
function generateConfigMock($values) {
|
||||
generate_mock_once('HTMLPurifier_Config');
|
||||
$config = new HTMLPurifier_ConfigMock($this);
|
||||
$config->setReturnValue('getBatch', $values, array('Test'));
|
||||
return $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an anonymous def that has been setup and named Test
|
||||
*/
|
||||
function generateDefinition($member_vars = array()) {
|
||||
$def = new HTMLPurifier_Definition();
|
||||
$def->setup = true;
|
||||
$def->type = 'Test';
|
||||
foreach ($member_vars as $key => $val) {
|
||||
$def->$key = $val;
|
||||
}
|
||||
return $def;
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that a file exists, ignoring the stat cache
|
||||
*/
|
||||
|
33
tests/HTMLPurifier/DefinitionCacheHarness.php
Normal file
33
tests/HTMLPurifier/DefinitionCacheHarness.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
class HTMLPurifier_DefinitionCacheHarness extends UnitTestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* Generate a configuration mock object that returns $values
|
||||
* to a getBatch() call
|
||||
* @param $values Values to return when getBatch is invoked
|
||||
*/
|
||||
function generateConfigMock($values) {
|
||||
generate_mock_once('HTMLPurifier_Config');
|
||||
$config = new HTMLPurifier_ConfigMock($this);
|
||||
$config->setReturnValue('getBatch', $values, array('Test'));
|
||||
return $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an anonymous def that has been setup and named Test
|
||||
*/
|
||||
function generateDefinition($member_vars = array()) {
|
||||
$def = new HTMLPurifier_Definition();
|
||||
$def->setup = true;
|
||||
$def->type = 'Test';
|
||||
foreach ($member_vars as $key => $val) {
|
||||
$def->$key = $val;
|
||||
}
|
||||
return $def;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
Loading…
Reference in New Issue
Block a user