2006-10-01 20:47:07 +00:00
|
|
|
<?php
|
|
|
|
|
2007-08-02 01:12:27 +00:00
|
|
|
require_once 'HTMLPurifier/URIParser.php';
|
|
|
|
|
2006-10-01 20:47:07 +00:00
|
|
|
/**
|
2007-08-01 14:06:59 +00:00
|
|
|
* All-use harness, use this rather than SimpleTest's
|
2006-10-01 20:47:07 +00:00
|
|
|
*/
|
|
|
|
class HTMLPurifier_Harness extends UnitTestCase
|
|
|
|
{
|
|
|
|
|
|
|
|
function HTMLPurifier_Harness() {
|
|
|
|
parent::UnitTestCase();
|
|
|
|
}
|
|
|
|
|
2007-08-01 18:34:46 +00:00
|
|
|
var $config, $context;
|
|
|
|
|
2007-08-02 01:12:27 +00:00
|
|
|
/**
|
|
|
|
* Generates easily accessible default config/context
|
|
|
|
*/
|
2007-08-01 18:34:46 +00:00
|
|
|
function setUp() {
|
|
|
|
list($this->config, $this->context) = $this->createCommon();
|
|
|
|
}
|
|
|
|
|
2007-08-02 01:12:27 +00:00
|
|
|
/**
|
|
|
|
* Accepts config and context and prepares them into a valid state
|
|
|
|
* @param &$config Reference to config variable
|
|
|
|
* @param &$context Reference to context variable
|
|
|
|
*/
|
2007-08-01 14:06:59 +00:00
|
|
|
function prepareCommon(&$config, &$context) {
|
|
|
|
$config = HTMLPurifier_Config::create($config);
|
|
|
|
if (!$context) $context = new HTMLPurifier_Context();
|
2006-10-01 20:47:07 +00:00
|
|
|
}
|
|
|
|
|
2007-08-02 01:12:27 +00:00
|
|
|
/**
|
|
|
|
* Generates default configuration and context objects
|
|
|
|
* @return Defaults in form of array($config, $context)
|
|
|
|
*/
|
2007-08-01 18:34:46 +00:00
|
|
|
function createCommon() {
|
|
|
|
return array(HTMLPurifier_Config::createDefault(), new HTMLPurifier_Context);
|
|
|
|
}
|
|
|
|
|
2007-08-02 01:12:27 +00:00
|
|
|
/**
|
|
|
|
* If $expect is false, ignore $result and check if status failed.
|
|
|
|
* Otherwise, check if $status if true and $result === $expect.
|
|
|
|
* @param $status Boolean status
|
|
|
|
* @param $result Mixed result from processing
|
|
|
|
* @param $expect Mixed expectation for result
|
|
|
|
*/
|
|
|
|
function assertEitherFailOrIdentical($status, $result, $expect) {
|
|
|
|
if ($expect === false) {
|
|
|
|
$this->assertFalse($status, 'Expected false result, got true');
|
|
|
|
} else {
|
|
|
|
$this->assertTrue($status, 'Expected true result, got false');
|
|
|
|
$this->assertIdentical($result, $expect);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-01 20:47:07 +00:00
|
|
|
}
|
|
|
|
|