mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-08-02 12:21:09 +02: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:
@@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
require_once 'HTMLPurifier/DefinitionCacheHarness.php';
|
||||||
require_once 'HTMLPurifier/DefinitionCache/Serializer.php';
|
require_once 'HTMLPurifier/DefinitionCache/Serializer.php';
|
||||||
|
|
||||||
class HTMLPurifier_Definition_SerializerMock extends HTMLPurifier_Definition
|
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() {
|
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
|
* 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
Reference in New Issue
Block a user