mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-11-09 23:28:42 +00:00
Classname() constructors to __construct() constructors, as per SimpleTest. Also normalized ppp declarations; no public declaration for test methods, public/protected for the rest
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1663 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
parent
5dbd455afb
commit
59605d592b
@ -12,7 +12,7 @@ class FSTools_FileSystemHarness extends UnitTestCase
|
|||||||
protected $dir, $oldDir;
|
protected $dir, $oldDir;
|
||||||
|
|
||||||
function __construct() {
|
function __construct() {
|
||||||
parent::UnitTestCase();
|
parent::__construct();
|
||||||
$this->dir = 'tmp/' . md5(uniqid(rand(), true)) . '/';
|
$this->dir = 'tmp/' . md5(uniqid(rand(), true)) . '/';
|
||||||
mkdir($this->dir);
|
mkdir($this->dir);
|
||||||
$this->oldDir = getcwd();
|
$this->oldDir = getcwd();
|
||||||
|
@ -6,7 +6,7 @@ class HTMLPurifier_AttrDefHarness extends HTMLPurifier_Harness
|
|||||||
protected $def;
|
protected $def;
|
||||||
protected $context, $config;
|
protected $context, $config;
|
||||||
|
|
||||||
function setUp() {
|
public function setUp() {
|
||||||
$this->config = HTMLPurifier_Config::createDefault();
|
$this->config = HTMLPurifier_Config::createDefault();
|
||||||
$this->context = new HTMLPurifier_Context();
|
$this->context = new HTMLPurifier_Context();
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
class HTMLPurifier_AttrTransformHarness extends HTMLPurifier_ComplexHarness
|
class HTMLPurifier_AttrTransformHarness extends HTMLPurifier_ComplexHarness
|
||||||
{
|
{
|
||||||
|
|
||||||
function setUp() {
|
public function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$this->func = 'transform';
|
$this->func = 'transform';
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
class HTMLPurifier_AttrValidator_ErrorsTest extends HTMLPurifier_ErrorsHarness
|
class HTMLPurifier_AttrValidator_ErrorsTest extends HTMLPurifier_ErrorsHarness
|
||||||
{
|
{
|
||||||
|
|
||||||
function invoke($input) {
|
protected function invoke($input) {
|
||||||
$validator = new HTMLPurifier_AttrValidator();
|
$validator = new HTMLPurifier_AttrValidator();
|
||||||
$validator->validateToken($input, $this->config, $this->context);
|
$validator->validateToken($input, $this->config, $this->context);
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
class HTMLPurifier_ChildDefHarness extends HTMLPurifier_ComplexHarness
|
class HTMLPurifier_ChildDefHarness extends HTMLPurifier_ComplexHarness
|
||||||
{
|
{
|
||||||
|
|
||||||
function setUp() {
|
public function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$this->obj = null;
|
$this->obj = null;
|
||||||
$this->func = 'validateChildren';
|
$this->func = 'validateChildren';
|
||||||
|
@ -50,10 +50,10 @@ class HTMLPurifier_ComplexHarness extends HTMLPurifier_Harness
|
|||||||
*/
|
*/
|
||||||
protected $context;
|
protected $context;
|
||||||
|
|
||||||
function HTMLPurifier_ComplexHarness() {
|
public function __construct() {
|
||||||
$this->lexer = new HTMLPurifier_Lexer_DirectLex();
|
$this->lexer = new HTMLPurifier_Lexer_DirectLex();
|
||||||
$this->generator = new HTMLPurifier_Generator();
|
$this->generator = new HTMLPurifier_Generator();
|
||||||
parent::HTMLPurifier_Harness();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -65,7 +65,7 @@ class HTMLPurifier_ComplexHarness extends HTMLPurifier_Harness
|
|||||||
* @param $context_array Context array in form of Key => Value or an actual
|
* @param $context_array Context array in form of Key => Value or an actual
|
||||||
* context object.
|
* context object.
|
||||||
*/
|
*/
|
||||||
function assertResult($input, $expect = true) {
|
protected function assertResult($input, $expect = true) {
|
||||||
|
|
||||||
if ($this->to_tokens && is_string($input)) {
|
if ($this->to_tokens && is_string($input)) {
|
||||||
// $func may cause $input to change, so "clone" another copy
|
// $func may cause $input to change, so "clone" another copy
|
||||||
@ -102,14 +102,14 @@ class HTMLPurifier_ComplexHarness extends HTMLPurifier_Harness
|
|||||||
/**
|
/**
|
||||||
* Tokenize HTML into tokens, uses member variables for common variables
|
* Tokenize HTML into tokens, uses member variables for common variables
|
||||||
*/
|
*/
|
||||||
function tokenize($html) {
|
protected function tokenize($html) {
|
||||||
return $this->lexer->tokenizeHTML($html, $this->config, $this->context);
|
return $this->lexer->tokenizeHTML($html, $this->config, $this->context);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate textual HTML from tokens
|
* Generate textual HTML from tokens
|
||||||
*/
|
*/
|
||||||
function generate($tokens) {
|
protected function generate($tokens) {
|
||||||
return $this->generator->generateFromTokens($tokens, $this->config, $this->context);
|
return $this->generator->generateFromTokens($tokens, $this->config, $this->context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,14 +9,14 @@ class HTMLPurifier_ConfigSchema_InterchangeTest extends UnitTestCase
|
|||||||
$this->interchange = new HTMLPurifier_ConfigSchema_Interchange();
|
$this->interchange = new HTMLPurifier_ConfigSchema_Interchange();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAddNamespace() {
|
function testAddNamespace() {
|
||||||
$v = new HTMLPurifier_ConfigSchema_Interchange_Namespace();
|
$v = new HTMLPurifier_ConfigSchema_Interchange_Namespace();
|
||||||
$v->namespace = 'Namespace';
|
$v->namespace = 'Namespace';
|
||||||
$this->interchange->addNamespace($v);
|
$this->interchange->addNamespace($v);
|
||||||
$this->assertIdentical($v, $this->interchange->namespaces['Namespace']);
|
$this->assertIdentical($v, $this->interchange->namespaces['Namespace']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAddDirective() {
|
function testAddDirective() {
|
||||||
$v = new HTMLPurifier_ConfigSchema_Interchange_Directive();
|
$v = new HTMLPurifier_ConfigSchema_Interchange_Directive();
|
||||||
$v->id = new HTMLPurifier_ConfigSchema_Interchange_Id('Namespace', 'Directive');
|
$v->id = new HTMLPurifier_ConfigSchema_Interchange_Id('Namespace', 'Directive');
|
||||||
$this->interchange->addDirective($v);
|
$this->interchange->addDirective($v);
|
||||||
|
@ -7,83 +7,83 @@ class HTMLPurifier_ConfigSchema_ValidatorAtomTest extends UnitTestCase
|
|||||||
$this->expectException(new HTMLPurifier_ConfigSchema_Exception($msg));
|
$this->expectException(new HTMLPurifier_ConfigSchema_Exception($msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function makeAtom($value) {
|
protected function makeAtom($value) {
|
||||||
$obj = new stdClass();
|
$obj = new stdClass();
|
||||||
$obj->property = $value;
|
$obj->property = $value;
|
||||||
// Note that 'property' and 'context' are magic wildcard values
|
// Note that 'property' and 'context' are magic wildcard values
|
||||||
return new HTMLPurifier_ConfigSchema_ValidatorAtom('context', $obj, 'property');
|
return new HTMLPurifier_ConfigSchema_ValidatorAtom('context', $obj, 'property');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAssertIsString() {
|
function testAssertIsString() {
|
||||||
$this->makeAtom('foo')->assertIsString();
|
$this->makeAtom('foo')->assertIsString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAssertIsStringFail() {
|
function testAssertIsStringFail() {
|
||||||
$this->expectValidationException("Property in context must be a string");
|
$this->expectValidationException("Property in context must be a string");
|
||||||
$this->makeAtom(3)->assertIsString();
|
$this->makeAtom(3)->assertIsString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAssertNotNull() {
|
function testAssertNotNull() {
|
||||||
$this->makeAtom('foo')->assertNotNull();
|
$this->makeAtom('foo')->assertNotNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAssertNotNullFail() {
|
function testAssertNotNullFail() {
|
||||||
$this->expectValidationException("Property in context must not be null");
|
$this->expectValidationException("Property in context must not be null");
|
||||||
$this->makeAtom(null)->assertNotNull();
|
$this->makeAtom(null)->assertNotNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAssertAlnum() {
|
function testAssertAlnum() {
|
||||||
$this->makeAtom('foo2')->assertAlnum();
|
$this->makeAtom('foo2')->assertAlnum();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAssertAlnumFail() {
|
function testAssertAlnumFail() {
|
||||||
$this->expectValidationException("Property in context must be alphanumeric");
|
$this->expectValidationException("Property in context must be alphanumeric");
|
||||||
$this->makeAtom('%a')->assertAlnum();
|
$this->makeAtom('%a')->assertAlnum();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAssertAlnumFailIsString() {
|
function testAssertAlnumFailIsString() {
|
||||||
$this->expectValidationException("Property in context must be a string");
|
$this->expectValidationException("Property in context must be a string");
|
||||||
$this->makeAtom(3)->assertAlnum();
|
$this->makeAtom(3)->assertAlnum();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAssertNotEmpty() {
|
function testAssertNotEmpty() {
|
||||||
$this->makeAtom('foo')->assertNotEmpty();
|
$this->makeAtom('foo')->assertNotEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAssertNotEmptyFail() {
|
function testAssertNotEmptyFail() {
|
||||||
$this->expectValidationException("Property in context must not be empty");
|
$this->expectValidationException("Property in context must not be empty");
|
||||||
$this->makeAtom('')->assertNotEmpty();
|
$this->makeAtom('')->assertNotEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAssertIsBool() {
|
function testAssertIsBool() {
|
||||||
$this->makeAtom(false)->assertIsBool();
|
$this->makeAtom(false)->assertIsBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAssertIsBoolFail() {
|
function testAssertIsBoolFail() {
|
||||||
$this->expectValidationException("Property in context must be a boolean");
|
$this->expectValidationException("Property in context must be a boolean");
|
||||||
$this->makeAtom('0')->assertIsBool();
|
$this->makeAtom('0')->assertIsBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAssertIsArray() {
|
function testAssertIsArray() {
|
||||||
$this->makeAtom(array())->assertIsArray();
|
$this->makeAtom(array())->assertIsArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAssertIsArrayFail() {
|
function testAssertIsArrayFail() {
|
||||||
$this->expectValidationException("Property in context must be an array");
|
$this->expectValidationException("Property in context must be an array");
|
||||||
$this->makeAtom('asdf')->assertIsArray();
|
$this->makeAtom('asdf')->assertIsArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function testAssertIsLookup() {
|
function testAssertIsLookup() {
|
||||||
$this->makeAtom(array('foo' => true))->assertIsLookup();
|
$this->makeAtom(array('foo' => true))->assertIsLookup();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAssertIsLookupFail() {
|
function testAssertIsLookupFail() {
|
||||||
$this->expectValidationException("Property in context must be a lookup array");
|
$this->expectValidationException("Property in context must be a lookup array");
|
||||||
$this->makeAtom(array('foo' => 4))->assertIsLookup();
|
$this->makeAtom(array('foo' => 4))->assertIsLookup();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAssertIsLookupFailIsArray() {
|
function testAssertIsLookupFailIsArray() {
|
||||||
$this->expectValidationException("Property in context must be an array");
|
$this->expectValidationException("Property in context must be an array");
|
||||||
$this->makeAtom('asdf')->assertIsLookup();
|
$this->makeAtom('asdf')->assertIsLookup();
|
||||||
}
|
}
|
||||||
|
@ -13,34 +13,34 @@ class HTMLPurifier_ConfigSchema_ValidatorTest extends UnitTestCase
|
|||||||
$this->interchange = new HTMLPurifier_ConfigSchema_Interchange();
|
$this->interchange = new HTMLPurifier_ConfigSchema_Interchange();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNamespaceIntegrityViolation() {
|
function testNamespaceIntegrityViolation() {
|
||||||
$ns = $this->makeNamespace('Ns');
|
$ns = $this->makeNamespace('Ns');
|
||||||
$ns->namespace = 'AltNs';
|
$ns->namespace = 'AltNs';
|
||||||
$this->expectValidationException("Integrity violation: key 'Ns' does not match internal id 'AltNs'");
|
$this->expectValidationException("Integrity violation: key 'Ns' does not match internal id 'AltNs'");
|
||||||
$this->validator->validate($this->interchange);
|
$this->validator->validate($this->interchange);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNamespaceNamespaceIsString() {
|
function testNamespaceNamespaceIsString() {
|
||||||
$this->makeNamespace(3);
|
$this->makeNamespace(3);
|
||||||
$this->expectValidationException("Namespace in namespace '3' must be a string");
|
$this->expectValidationException("Namespace in namespace '3' must be a string");
|
||||||
$this->validator->validate($this->interchange);
|
$this->validator->validate($this->interchange);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNamespaceDescriptionIsString() {
|
function testNamespaceDescriptionIsString() {
|
||||||
$ns = $this->makeNamespace('Ns');
|
$ns = $this->makeNamespace('Ns');
|
||||||
$ns->description = 3;
|
$ns->description = 3;
|
||||||
$this->expectValidationException("Description in namespace 'Ns' must be a string");
|
$this->expectValidationException("Description in namespace 'Ns' must be a string");
|
||||||
$this->validator->validate($this->interchange);
|
$this->validator->validate($this->interchange);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDirectiveIntegrityViolation() {
|
function testDirectiveIntegrityViolation() {
|
||||||
$d = $this->makeDirective('Ns', 'Dir');
|
$d = $this->makeDirective('Ns', 'Dir');
|
||||||
$d->id = new HTMLPurifier_ConfigSchema_Interchange_Id('Ns', 'Dir2');
|
$d->id = new HTMLPurifier_ConfigSchema_Interchange_Id('Ns', 'Dir2');
|
||||||
$this->expectValidationException("Integrity violation: key 'Ns.Dir' does not match internal id 'Ns.Dir2'");
|
$this->expectValidationException("Integrity violation: key 'Ns.Dir' does not match internal id 'Ns.Dir2'");
|
||||||
$this->validator->validate($this->interchange);
|
$this->validator->validate($this->interchange);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDirectiveTypeNotEmpty() {
|
function testDirectiveTypeNotEmpty() {
|
||||||
$this->makeNamespace('Ns');
|
$this->makeNamespace('Ns');
|
||||||
$d = $this->makeDirective('Ns', 'Dir');
|
$d = $this->makeDirective('Ns', 'Dir');
|
||||||
$d->default = 0;
|
$d->default = 0;
|
||||||
@ -50,7 +50,7 @@ class HTMLPurifier_ConfigSchema_ValidatorTest extends UnitTestCase
|
|||||||
$this->validator->validate($this->interchange);
|
$this->validator->validate($this->interchange);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDirectiveDefaultInvalid() {
|
function testDirectiveDefaultInvalid() {
|
||||||
$this->makeNamespace('Ns');
|
$this->makeNamespace('Ns');
|
||||||
$d = $this->makeDirective('Ns', 'Dir');
|
$d = $this->makeDirective('Ns', 'Dir');
|
||||||
$d->default = 'asdf';
|
$d->default = 'asdf';
|
||||||
@ -61,7 +61,7 @@ class HTMLPurifier_ConfigSchema_ValidatorTest extends UnitTestCase
|
|||||||
$this->validator->validate($this->interchange);
|
$this->validator->validate($this->interchange);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDirectiveIdDirectiveIsString() {
|
function testDirectiveIdDirectiveIsString() {
|
||||||
$this->makeNamespace('Ns');
|
$this->makeNamespace('Ns');
|
||||||
$d = $this->makeDirective('Ns', 3);
|
$d = $this->makeDirective('Ns', 3);
|
||||||
$d->default = 0;
|
$d->default = 0;
|
||||||
@ -72,7 +72,7 @@ class HTMLPurifier_ConfigSchema_ValidatorTest extends UnitTestCase
|
|||||||
$this->validator->validate($this->interchange);
|
$this->validator->validate($this->interchange);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDirectiveTypeAllowsNullIsBool() {
|
function testDirectiveTypeAllowsNullIsBool() {
|
||||||
$this->makeNamespace('Ns');
|
$this->makeNamespace('Ns');
|
||||||
$d = $this->makeDirective('Ns', 'Dir');
|
$d = $this->makeDirective('Ns', 'Dir');
|
||||||
$d->default = 0;
|
$d->default = 0;
|
||||||
@ -84,7 +84,7 @@ class HTMLPurifier_ConfigSchema_ValidatorTest extends UnitTestCase
|
|||||||
$this->validator->validate($this->interchange);
|
$this->validator->validate($this->interchange);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDirectiveValueAliasesIsArray() {
|
function testDirectiveValueAliasesIsArray() {
|
||||||
$this->makeNamespace('Ns');
|
$this->makeNamespace('Ns');
|
||||||
$d = $this->makeDirective('Ns', 'Dir');
|
$d = $this->makeDirective('Ns', 'Dir');
|
||||||
$d->default = 'a';
|
$d->default = 'a';
|
||||||
@ -96,7 +96,7 @@ class HTMLPurifier_ConfigSchema_ValidatorTest extends UnitTestCase
|
|||||||
$this->validator->validate($this->interchange);
|
$this->validator->validate($this->interchange);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDirectiveAllowedIsLookup() {
|
function testDirectiveAllowedIsLookup() {
|
||||||
$this->makeNamespace('Ns');
|
$this->makeNamespace('Ns');
|
||||||
$d = $this->makeDirective('Ns', 'Dir');
|
$d = $this->makeDirective('Ns', 'Dir');
|
||||||
$d->default = 'foo';
|
$d->default = 'foo';
|
||||||
|
@ -13,14 +13,14 @@ class HTMLPurifier_ConfigSchema_ValidatorTestCase extends UnitTestCase
|
|||||||
$this->_path = $path;
|
$this->_path = $path;
|
||||||
$this->_parser = new HTMLPurifier_StringHashParser();
|
$this->_parser = new HTMLPurifier_StringHashParser();
|
||||||
$this->_builder = new HTMLPurifier_ConfigSchema_InterchangeBuilder();
|
$this->_builder = new HTMLPurifier_ConfigSchema_InterchangeBuilder();
|
||||||
parent::UnitTestCase($path);
|
parent::__construct($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setup() {
|
public function setup() {
|
||||||
$this->validator = new HTMLPurifier_ConfigSchema_Validator();
|
$this->validator = new HTMLPurifier_ConfigSchema_Validator();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testValidator() {
|
function testValidator() {
|
||||||
$hashes = $this->_parser->parseMultiFile($this->_path);
|
$hashes = $this->_parser->parseMultiFile($this->_path);
|
||||||
$interchange = new HTMLPurifier_ConfigSchema_Interchange();
|
$interchange = new HTMLPurifier_ConfigSchema_Interchange();
|
||||||
$error = null;
|
$error = null;
|
||||||
|
@ -5,7 +5,7 @@ class HTMLPurifier_ConfigSchemaTest extends HTMLPurifier_Harness
|
|||||||
|
|
||||||
protected $schema;
|
protected $schema;
|
||||||
|
|
||||||
function setup() {
|
public function setup() {
|
||||||
$this->schema = new HTMLPurifier_ConfigSchema();
|
$this->schema = new HTMLPurifier_ConfigSchema();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ class HTMLPurifier_ConfigTest extends HTMLPurifier_Harness
|
|||||||
|
|
||||||
protected $schema;
|
protected $schema;
|
||||||
|
|
||||||
function setUp() {
|
public function setUp() {
|
||||||
// set up a dummy schema object for testing
|
// set up a dummy schema object for testing
|
||||||
$this->schema = new HTMLPurifier_ConfigSchema();
|
$this->schema = new HTMLPurifier_ConfigSchema();
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ class HTMLPurifier_ContextTest extends HTMLPurifier_Harness
|
|||||||
|
|
||||||
protected $context;
|
protected $context;
|
||||||
|
|
||||||
function setUp() {
|
public function setUp() {
|
||||||
$this->context = new HTMLPurifier_Context();
|
$this->context = new HTMLPurifier_Context();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,14 +6,14 @@ class HTMLPurifier_DefinitionCacheFactoryTest extends HTMLPurifier_Harness
|
|||||||
protected $factory;
|
protected $factory;
|
||||||
protected $oldFactory;
|
protected $oldFactory;
|
||||||
|
|
||||||
function setup() {
|
public function setUp() {
|
||||||
parent::setup();
|
parent::setup();
|
||||||
$this->factory = new HTMLPurifier_DefinitionCacheFactory();
|
$this->factory = new HTMLPurifier_DefinitionCacheFactory();
|
||||||
$this->oldFactory = HTMLPurifier_DefinitionCacheFactory::instance();
|
$this->oldFactory = HTMLPurifier_DefinitionCacheFactory::instance();
|
||||||
HTMLPurifier_DefinitionCacheFactory::instance($this->factory);
|
HTMLPurifier_DefinitionCacheFactory::instance($this->factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
function teardown() {
|
public function tearDown() {
|
||||||
HTMLPurifier_DefinitionCacheFactory::instance($this->oldFactory);
|
HTMLPurifier_DefinitionCacheFactory::instance($this->oldFactory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ class HTMLPurifier_DefinitionCacheHarness extends HTMLPurifier_Harness
|
|||||||
* to a getBatch() call
|
* to a getBatch() call
|
||||||
* @param $values Values to return when getBatch is invoked
|
* @param $values Values to return when getBatch is invoked
|
||||||
*/
|
*/
|
||||||
function generateConfigMock($serial = 'defaultserial') {
|
protected function generateConfigMock($serial = 'defaultserial') {
|
||||||
generate_mock_once('HTMLPurifier_Config');
|
generate_mock_once('HTMLPurifier_Config');
|
||||||
$config = new HTMLPurifier_ConfigMock();
|
$config = new HTMLPurifier_ConfigMock();
|
||||||
$config->setReturnValue('getBatchSerial', $serial, array('Test'));
|
$config->setReturnValue('getBatchSerial', $serial, array('Test'));
|
||||||
@ -19,7 +19,7 @@ class HTMLPurifier_DefinitionCacheHarness extends HTMLPurifier_Harness
|
|||||||
/**
|
/**
|
||||||
* Returns an anonymous def that has been setup and named Test
|
* Returns an anonymous def that has been setup and named Test
|
||||||
*/
|
*/
|
||||||
function generateDefinition($member_vars = array()) {
|
protected function generateDefinition($member_vars = array()) {
|
||||||
$def = new HTMLPurifier_DefinitionTestable();
|
$def = new HTMLPurifier_DefinitionTestable();
|
||||||
$def->setup = true;
|
$def->setup = true;
|
||||||
$def->type = 'Test';
|
$def->type = 'Test';
|
||||||
|
@ -5,7 +5,7 @@ class HTMLPurifier_EntityParserTest extends HTMLPurifier_Harness
|
|||||||
|
|
||||||
protected $EntityParser;
|
protected $EntityParser;
|
||||||
|
|
||||||
function setUp() {
|
public function setUp() {
|
||||||
$this->EntityParser = new HTMLPurifier_EntityParser();
|
$this->EntityParser = new HTMLPurifier_EntityParser();
|
||||||
$this->_entity_lookup = HTMLPurifier_EntityLookup::instance();
|
$this->_entity_lookup = HTMLPurifier_EntityLookup::instance();
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
class HTMLPurifier_ErrorCollectorTest extends HTMLPurifier_Harness
|
class HTMLPurifier_ErrorCollectorTest extends HTMLPurifier_Harness
|
||||||
{
|
{
|
||||||
|
|
||||||
function setup() {
|
public function setup() {
|
||||||
generate_mock_once('HTMLPurifier_Language');
|
generate_mock_once('HTMLPurifier_Language');
|
||||||
generate_mock_once('HTMLPurifier_Generator');
|
generate_mock_once('HTMLPurifier_Generator');
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ class HTMLPurifier_ErrorsHarness extends HTMLPurifier_Harness
|
|||||||
protected $config, $context;
|
protected $config, $context;
|
||||||
protected $collector, $generator, $callCount;
|
protected $collector, $generator, $callCount;
|
||||||
|
|
||||||
function setup() {
|
public function setup() {
|
||||||
$this->config = HTMLPurifier_Config::create(array('Core.CollectErrors' => true));
|
$this->config = HTMLPurifier_Config::create(array('Core.CollectErrors' => true));
|
||||||
$this->context = new HTMLPurifier_Context();
|
$this->context = new HTMLPurifier_Context();
|
||||||
generate_mock_once('HTMLPurifier_ErrorCollector');
|
generate_mock_once('HTMLPurifier_ErrorCollector');
|
||||||
@ -20,16 +20,16 @@ class HTMLPurifier_ErrorsHarness extends HTMLPurifier_Harness
|
|||||||
$this->callCount = 0;
|
$this->callCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function expectNoErrorCollection() {
|
protected function expectNoErrorCollection() {
|
||||||
$this->collector->expectNever('send');
|
$this->collector->expectNever('send');
|
||||||
}
|
}
|
||||||
|
|
||||||
function expectErrorCollection() {
|
protected function expectErrorCollection() {
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
$this->collector->expectOnce('send', $args);
|
$this->collector->expectOnce('send', $args);
|
||||||
}
|
}
|
||||||
|
|
||||||
function expectContext($key, $value) {
|
protected function expectContext($key, $value) {
|
||||||
$this->collector->expectContext($key, $value);
|
$this->collector->expectContext($key, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,13 +7,13 @@ class HTMLPurifier_GeneratorTest extends HTMLPurifier_ComplexHarness
|
|||||||
protected $_entity_lookup;
|
protected $_entity_lookup;
|
||||||
protected $config;
|
protected $config;
|
||||||
|
|
||||||
function HTMLPurifier_GeneratorTest() {
|
public function __construct() {
|
||||||
$this->HTMLPurifier_Harness();
|
parent::__construct();
|
||||||
$this->gen = new HTMLPurifier_Generator();
|
$this->gen = new HTMLPurifier_Generator();
|
||||||
$this->_entity_lookup = HTMLPurifier_EntityLookup::instance();
|
$this->_entity_lookup = HTMLPurifier_EntityLookup::instance();
|
||||||
}
|
}
|
||||||
|
|
||||||
function setUp() {
|
public function setUp() {
|
||||||
$this->obj = new HTMLPurifier_Generator();
|
$this->obj = new HTMLPurifier_Generator();
|
||||||
$this->func = null;
|
$this->func = null;
|
||||||
$this->to_tokens = false;
|
$this->to_tokens = false;
|
||||||
@ -115,7 +115,7 @@ class HTMLPurifier_GeneratorTest extends HTMLPurifier_ComplexHarness
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function assertGeneration($tokens, $expect) {
|
protected function assertGeneration($tokens, $expect) {
|
||||||
$context = new HTMLPurifier_Context();
|
$context = new HTMLPurifier_Context();
|
||||||
$result = $this->gen->generateFromTokens(
|
$result = $this->gen->generateFromTokens(
|
||||||
$tokens, $this->config, $context);
|
$tokens, $this->config, $context);
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
class HTMLPurifier_Harness extends UnitTestCase
|
class HTMLPurifier_Harness extends UnitTestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
function HTMLPurifier_Harness() {
|
public function __construct() {
|
||||||
parent::UnitTestCase();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected $config, $context;
|
protected $config, $context;
|
||||||
@ -15,7 +15,7 @@ class HTMLPurifier_Harness extends UnitTestCase
|
|||||||
/**
|
/**
|
||||||
* Generates easily accessible default config/context
|
* Generates easily accessible default config/context
|
||||||
*/
|
*/
|
||||||
function setUp() {
|
public function setUp() {
|
||||||
list($this->config, $this->context) = $this->createCommon();
|
list($this->config, $this->context) = $this->createCommon();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ class HTMLPurifier_Harness extends UnitTestCase
|
|||||||
* @param &$config Reference to config variable
|
* @param &$config Reference to config variable
|
||||||
* @param &$context Reference to context variable
|
* @param &$context Reference to context variable
|
||||||
*/
|
*/
|
||||||
function prepareCommon(&$config, &$context) {
|
protected function prepareCommon(&$config, &$context) {
|
||||||
$config = HTMLPurifier_Config::create($config);
|
$config = HTMLPurifier_Config::create($config);
|
||||||
if (!$context) $context = new HTMLPurifier_Context();
|
if (!$context) $context = new HTMLPurifier_Context();
|
||||||
}
|
}
|
||||||
@ -33,14 +33,14 @@ class HTMLPurifier_Harness extends UnitTestCase
|
|||||||
* Generates default configuration and context objects
|
* Generates default configuration and context objects
|
||||||
* @return Defaults in form of array($config, $context)
|
* @return Defaults in form of array($config, $context)
|
||||||
*/
|
*/
|
||||||
function createCommon() {
|
protected function createCommon() {
|
||||||
return array(HTMLPurifier_Config::createDefault(), new HTMLPurifier_Context);
|
return array(HTMLPurifier_Config::createDefault(), new HTMLPurifier_Context);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Normalizes a string to Unix (\n) endings
|
* Normalizes a string to Unix (\n) endings
|
||||||
*/
|
*/
|
||||||
function normalize(&$string) {
|
protected function normalize(&$string) {
|
||||||
$string = str_replace(array("\r\n", "\r"), "\n", $string);
|
$string = str_replace(array("\r\n", "\r"), "\n", $string);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ class HTMLPurifier_Harness extends UnitTestCase
|
|||||||
* @param $result Mixed result from processing
|
* @param $result Mixed result from processing
|
||||||
* @param $expect Mixed expectation for result
|
* @param $expect Mixed expectation for result
|
||||||
*/
|
*/
|
||||||
function assertEitherFailOrIdentical($status, $result, $expect) {
|
protected function assertEitherFailOrIdentical($status, $result, $expect) {
|
||||||
if ($expect === false) {
|
if ($expect === false) {
|
||||||
$this->assertFalse($status, 'Expected false result, got true');
|
$this->assertFalse($status, 'Expected false result, got true');
|
||||||
} else {
|
} else {
|
||||||
@ -60,7 +60,7 @@ class HTMLPurifier_Harness extends UnitTestCase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTests() {
|
public function getTests() {
|
||||||
// __onlytest makes only one test get triggered
|
// __onlytest makes only one test get triggered
|
||||||
foreach (get_class_methods(get_class($this)) as $method) {
|
foreach (get_class_methods(get_class($this)) as $method) {
|
||||||
if (strtolower(substr($method, 0, 10)) == '__onlytest') {
|
if (strtolower(substr($method, 0, 10)) == '__onlytest') {
|
||||||
|
@ -8,7 +8,7 @@ class HTMLPurifier_LanguageTest extends HTMLPurifier_Harness
|
|||||||
|
|
||||||
protected $lang;
|
protected $lang;
|
||||||
|
|
||||||
function generateEnLanguage() {
|
protected function generateEnLanguage() {
|
||||||
$factory = HTMLPurifier_LanguageFactory::instance();
|
$factory = HTMLPurifier_LanguageFactory::instance();
|
||||||
$config = HTMLPurifier_Config::create(array('Core.Language' => 'en'));
|
$config = HTMLPurifier_Config::create(array('Core.Language' => 'en'));
|
||||||
$context = new HTMLPurifier_Context();
|
$context = new HTMLPurifier_Context();
|
||||||
|
@ -5,8 +5,8 @@ class HTMLPurifier_LexerTest extends HTMLPurifier_Harness
|
|||||||
|
|
||||||
protected $_has_pear = false;
|
protected $_has_pear = false;
|
||||||
|
|
||||||
function HTMLPurifier_LexerTest() {
|
public function __construct() {
|
||||||
parent::HTMLPurifier_Harness();
|
parent::__construct();
|
||||||
// E_STRICT = 2048, int used for PHP4 compat: this check disables
|
// E_STRICT = 2048, int used for PHP4 compat: this check disables
|
||||||
// PEAR if PHP 5 strict mode is on, since the class is not strict safe
|
// PEAR if PHP 5 strict mode is on, since the class is not strict safe
|
||||||
if (
|
if (
|
||||||
|
@ -7,7 +7,7 @@ class HTMLPurifier_SimpleTest_Reporter extends HTMLReporter
|
|||||||
|
|
||||||
public function __construct($encoding, $ac) {
|
public function __construct($encoding, $ac) {
|
||||||
$this->ac = $ac;
|
$this->ac = $ac;
|
||||||
parent::HTMLReporter($encoding);
|
parent::__construct($encoding);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function paintHeader($test_name) {
|
public function paintHeader($test_name) {
|
||||||
|
@ -4,9 +4,9 @@ class HTMLPurifier_Strategy_ErrorsHarness extends HTMLPurifier_ErrorsHarness
|
|||||||
{
|
{
|
||||||
|
|
||||||
// needs to be defined
|
// needs to be defined
|
||||||
function getStrategy() {}
|
protected function getStrategy() {}
|
||||||
|
|
||||||
function invoke($input) {
|
protected function invoke($input) {
|
||||||
$strategy = $this->getStrategy();
|
$strategy = $this->getStrategy();
|
||||||
$lexer = new HTMLPurifier_Lexer_DirectLex();
|
$lexer = new HTMLPurifier_Lexer_DirectLex();
|
||||||
$tokens = $lexer->tokenizeHTML($input, $this->config, $this->context);
|
$tokens = $lexer->tokenizeHTML($input, $this->config, $this->context);
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
class HTMLPurifier_Strategy_FixNesting_ErrorsTest extends HTMLPurifier_Strategy_ErrorsHarness
|
class HTMLPurifier_Strategy_FixNesting_ErrorsTest extends HTMLPurifier_Strategy_ErrorsHarness
|
||||||
{
|
{
|
||||||
|
|
||||||
function getStrategy() {
|
protected function getStrategy() {
|
||||||
return new HTMLPurifier_Strategy_FixNesting();
|
return new HTMLPurifier_Strategy_FixNesting();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
class HTMLPurifier_Strategy_MakeWellFormed_ErrorsTest extends HTMLPurifier_Strategy_ErrorsHarness
|
class HTMLPurifier_Strategy_MakeWellFormed_ErrorsTest extends HTMLPurifier_Strategy_ErrorsHarness
|
||||||
{
|
{
|
||||||
|
|
||||||
function getStrategy() {
|
protected function getStrategy() {
|
||||||
return new HTMLPurifier_Strategy_MakeWellFormed();
|
return new HTMLPurifier_Strategy_MakeWellFormed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,12 +3,12 @@
|
|||||||
class HTMLPurifier_Strategy_RemoveForeignElements_ErrorsTest extends HTMLPurifier_Strategy_ErrorsHarness
|
class HTMLPurifier_Strategy_RemoveForeignElements_ErrorsTest extends HTMLPurifier_Strategy_ErrorsHarness
|
||||||
{
|
{
|
||||||
|
|
||||||
function setup() {
|
public function setup() {
|
||||||
parent::setup();
|
parent::setup();
|
||||||
$this->config->set('HTML', 'TidyLevel', 'heavy');
|
$this->config->set('HTML', 'TidyLevel', 'heavy');
|
||||||
}
|
}
|
||||||
|
|
||||||
function getStrategy() {
|
protected function getStrategy() {
|
||||||
return new HTMLPurifier_Strategy_RemoveForeignElements();
|
return new HTMLPurifier_Strategy_RemoveForeignElements();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,12 +18,12 @@ class HTMLPurifier_StringHashParserTest extends UnitTestCase
|
|||||||
/**
|
/**
|
||||||
* Assert that $file gets parsed into the form of $expect
|
* Assert that $file gets parsed into the form of $expect
|
||||||
*/
|
*/
|
||||||
public function assertParse($file, $expect) {
|
protected function assertParse($file, $expect) {
|
||||||
$result = $this->parser->parseFile(dirname(__FILE__) . '/StringHashParser/' . $file);
|
$result = $this->parser->parseFile(dirname(__FILE__) . '/StringHashParser/' . $file);
|
||||||
$this->assertIdentical($result, $expect);
|
$this->assertIdentical($result, $expect);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSimple() {
|
function testSimple() {
|
||||||
$this->assertParse('Simple.txt', array(
|
$this->assertParse('Simple.txt', array(
|
||||||
'ID' => 'Namespace.Directive',
|
'ID' => 'Namespace.Directive',
|
||||||
'TYPE' => 'string',
|
'TYPE' => 'string',
|
||||||
@ -33,26 +33,26 @@ class HTMLPurifier_StringHashParserTest extends UnitTestCase
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testOverrideSingle() {
|
function testOverrideSingle() {
|
||||||
$this->assertParse('OverrideSingle.txt', array(
|
$this->assertParse('OverrideSingle.txt', array(
|
||||||
'KEY' => 'New',
|
'KEY' => 'New',
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAppendMultiline() {
|
function testAppendMultiline() {
|
||||||
$this->assertParse('AppendMultiline.txt', array(
|
$this->assertParse('AppendMultiline.txt', array(
|
||||||
'KEY' => "Line1\nLine2\n",
|
'KEY' => "Line1\nLine2\n",
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDefault() {
|
function testDefault() {
|
||||||
$this->parser->default = 'NEW-ID';
|
$this->parser->default = 'NEW-ID';
|
||||||
$this->assertParse('Default.txt', array(
|
$this->assertParse('Default.txt', array(
|
||||||
'NEW-ID' => 'DefaultValue',
|
'NEW-ID' => 'DefaultValue',
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testError() {
|
function testError() {
|
||||||
try {
|
try {
|
||||||
$this->parser->parseFile('NoExist.txt');
|
$this->parser->parseFile('NoExist.txt');
|
||||||
} catch (HTMLPurifier_ConfigSchema_Exception $e) {
|
} catch (HTMLPurifier_ConfigSchema_Exception $e) {
|
||||||
@ -60,7 +60,7 @@ class HTMLPurifier_StringHashParserTest extends UnitTestCase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testParseMultiple() {
|
function testParseMultiple() {
|
||||||
$result = $this->parser->parseMultiFile(dirname(__FILE__) . '/StringHashParser/Multi.txt');
|
$result = $this->parser->parseMultiFile(dirname(__FILE__) . '/StringHashParser/Multi.txt');
|
||||||
$this->assertIdentical(
|
$this->assertIdentical(
|
||||||
$result,
|
$result,
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
class HTMLPurifier_StringHashTest extends UnitTestCase
|
class HTMLPurifier_StringHashTest extends UnitTestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
public function testUsed() {
|
function testUsed() {
|
||||||
$hash = new HTMLPurifier_StringHash(array(
|
$hash = new HTMLPurifier_StringHash(array(
|
||||||
'key' => 'value',
|
'key' => 'value',
|
||||||
'key2' => 'value2'
|
'key2' => 'value2'
|
||||||
|
@ -30,7 +30,7 @@ class HTMLPurifier_TagTransformTest extends HTMLPurifier_Harness
|
|||||||
* @param $config_array Configuration array for HTMLPurifier_Config
|
* @param $config_array Configuration array for HTMLPurifier_Config
|
||||||
* @param $context_array Context array for HTMLPurifier_Context
|
* @param $context_array Context array for HTMLPurifier_Context
|
||||||
*/
|
*/
|
||||||
function assertTransformation($transformer,
|
protected function assertTransformation($transformer,
|
||||||
$name, $attributes,
|
$name, $attributes,
|
||||||
$expect_name, $expect_attributes,
|
$expect_name, $expect_attributes,
|
||||||
$expect_added_attributes = array(),
|
$expect_added_attributes = array(),
|
||||||
@ -119,7 +119,7 @@ class HTMLPurifier_TagTransformTest extends HTMLPurifier_Harness
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function assertSizeToStyle($transformer, $size, $style) {
|
protected function assertSizeToStyle($transformer, $size, $style) {
|
||||||
$this->assertTransformation(
|
$this->assertTransformation(
|
||||||
$transformer,
|
$transformer,
|
||||||
'font', array('size' => $size),
|
'font', array('size' => $size),
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
class HTMLPurifier_TokenTest extends HTMLPurifier_Harness
|
class HTMLPurifier_TokenTest extends HTMLPurifier_Harness
|
||||||
{
|
{
|
||||||
|
|
||||||
function assertTokenConstruction($name, $attr,
|
protected function assertTokenConstruction($name, $attr,
|
||||||
$expect_name = null, $expect_attr = null
|
$expect_name = null, $expect_attr = null
|
||||||
) {
|
) {
|
||||||
if ($expect_name === null) $expect_name = $name;
|
if ($expect_name === null) $expect_name = $name;
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
class HTMLPurifier_URIDefinitionTest extends HTMLPurifier_URIHarness
|
class HTMLPurifier_URIDefinitionTest extends HTMLPurifier_URIHarness
|
||||||
{
|
{
|
||||||
|
|
||||||
function createFilterMock($expect = true, $result = true) {
|
protected function createFilterMock($expect = true, $result = true) {
|
||||||
static $i = 0;
|
static $i = 0;
|
||||||
generate_mock_once('HTMLPurifier_URIFilter');
|
generate_mock_once('HTMLPurifier_URIFilter');
|
||||||
$mock = new HTMLPurifier_URIFilterMock();
|
$mock = new HTMLPurifier_URIFilterMock();
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
class HTMLPurifier_URIFilterHarness extends HTMLPurifier_URIHarness
|
class HTMLPurifier_URIFilterHarness extends HTMLPurifier_URIHarness
|
||||||
{
|
{
|
||||||
|
|
||||||
function assertFiltering($uri, $expect_uri = true) {
|
protected function assertFiltering($uri, $expect_uri = true) {
|
||||||
$this->prepareURI($uri, $expect_uri);
|
$this->prepareURI($uri, $expect_uri);
|
||||||
$this->filter->prepare($this->config, $this->context);
|
$this->filter->prepare($this->config, $this->context);
|
||||||
$result = $this->filter->filter($uri, $this->config, $this->context);
|
$result = $this->filter->filter($uri, $this->config, $this->context);
|
||||||
|
@ -9,7 +9,7 @@ class HTMLPurifier_URIHarness extends HTMLPurifier_Harness
|
|||||||
* @param &$expect_uri Reference to string expectation URI
|
* @param &$expect_uri Reference to string expectation URI
|
||||||
* @note If $expect_uri is false, it will stay false
|
* @note If $expect_uri is false, it will stay false
|
||||||
*/
|
*/
|
||||||
function prepareURI(&$uri, &$expect_uri) {
|
protected function prepareURI(&$uri, &$expect_uri) {
|
||||||
$parser = new HTMLPurifier_URIParser();
|
$parser = new HTMLPurifier_URIParser();
|
||||||
if ($expect_uri === true) $expect_uri = $uri;
|
if ($expect_uri === true) $expect_uri = $uri;
|
||||||
$uri = $parser->parse($uri);
|
$uri = $parser->parse($uri);
|
||||||
@ -21,7 +21,7 @@ class HTMLPurifier_URIHarness extends HTMLPurifier_Harness
|
|||||||
/**
|
/**
|
||||||
* Generates a URI object from the corresponding string
|
* Generates a URI object from the corresponding string
|
||||||
*/
|
*/
|
||||||
function createURI($uri) {
|
protected function createURI($uri) {
|
||||||
$parser = new HTMLPurifier_URIParser();
|
$parser = new HTMLPurifier_URIParser();
|
||||||
return $parser->parse($uri);
|
return $parser->parse($uri);
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
class HTMLPurifier_URIParserTest extends HTMLPurifier_Harness
|
class HTMLPurifier_URIParserTest extends HTMLPurifier_Harness
|
||||||
{
|
{
|
||||||
|
|
||||||
function assertParsing(
|
protected function assertParsing(
|
||||||
$uri, $scheme, $userinfo, $host, $port, $path, $query, $fragment, $config = null, $context = null
|
$uri, $scheme, $userinfo, $host, $port, $path, $query, $fragment, $config = null, $context = null
|
||||||
) {
|
) {
|
||||||
$this->prepareCommon($config, $context);
|
$this->prepareCommon($config, $context);
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
class HTMLPurifier_URISchemeTest extends HTMLPurifier_URIHarness
|
class HTMLPurifier_URISchemeTest extends HTMLPurifier_URIHarness
|
||||||
{
|
{
|
||||||
|
|
||||||
function assertValidation($uri, $expect_uri = true) {
|
protected function assertValidation($uri, $expect_uri = true) {
|
||||||
$this->prepareURI($uri, $expect_uri);
|
$this->prepareURI($uri, $expect_uri);
|
||||||
// convenience hack: the scheme should be explicitly specified
|
// convenience hack: the scheme should be explicitly specified
|
||||||
$scheme = $uri->getSchemeObj($this->config, $this->context);
|
$scheme = $uri->getSchemeObj($this->config, $this->context);
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
class HTMLPurifier_URITest extends HTMLPurifier_URIHarness
|
class HTMLPurifier_URITest extends HTMLPurifier_URIHarness
|
||||||
{
|
{
|
||||||
|
|
||||||
function createURI($uri) {
|
protected function createURI($uri) {
|
||||||
$parser = new HTMLPurifier_URIParser();
|
$parser = new HTMLPurifier_URIParser();
|
||||||
return $parser->parse($uri);
|
return $parser->parse($uri);
|
||||||
}
|
}
|
||||||
@ -16,7 +16,7 @@ class HTMLPurifier_URITest extends HTMLPurifier_URIHarness
|
|||||||
|
|
||||||
protected $oldRegistry;
|
protected $oldRegistry;
|
||||||
|
|
||||||
function &setUpSchemeRegistryMock() {
|
protected function &setUpSchemeRegistryMock() {
|
||||||
$this->oldRegistry = HTMLPurifier_URISchemeRegistry::instance();
|
$this->oldRegistry = HTMLPurifier_URISchemeRegistry::instance();
|
||||||
generate_mock_once('HTMLPurifier_URIScheme');
|
generate_mock_once('HTMLPurifier_URIScheme');
|
||||||
generate_mock_once('HTMLPurifier_URISchemeRegistry');
|
generate_mock_once('HTMLPurifier_URISchemeRegistry');
|
||||||
@ -26,19 +26,19 @@ class HTMLPurifier_URITest extends HTMLPurifier_URIHarness
|
|||||||
return $registry;
|
return $registry;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setUpSchemeMock($name) {
|
protected function setUpSchemeMock($name) {
|
||||||
$registry = $this->setUpSchemeRegistryMock();
|
$registry = $this->setUpSchemeRegistryMock();
|
||||||
$scheme_mock = new HTMLPurifier_URISchemeMock();
|
$scheme_mock = new HTMLPurifier_URISchemeMock();
|
||||||
$registry->setReturnValue('getScheme', $scheme_mock, array($name, '*', '*'));
|
$registry->setReturnValue('getScheme', $scheme_mock, array($name, '*', '*'));
|
||||||
return $scheme_mock;
|
return $scheme_mock;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setUpNoValidSchemes() {
|
protected function setUpNoValidSchemes() {
|
||||||
$registry = $this->setUpSchemeRegistryMock();
|
$registry = $this->setUpSchemeRegistryMock();
|
||||||
$registry->setReturnValue('getScheme', false, array('*', '*', '*'));
|
$registry->setReturnValue('getScheme', false, array('*', '*', '*'));
|
||||||
}
|
}
|
||||||
|
|
||||||
function tearDownSchemeRegistryMock() {
|
protected function tearDownSchemeRegistryMock() {
|
||||||
HTMLPurifier_URISchemeRegistry::instance($this->oldRegistry);
|
HTMLPurifier_URISchemeRegistry::instance($this->oldRegistry);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ class HTMLPurifier_URITest extends HTMLPurifier_URIHarness
|
|||||||
$this->tearDownSchemeRegistryMock();
|
$this->tearDownSchemeRegistryMock();
|
||||||
}
|
}
|
||||||
|
|
||||||
function assertToString($expect_uri, $scheme, $userinfo, $host, $port, $path, $query, $fragment) {
|
protected function assertToString($expect_uri, $scheme, $userinfo, $host, $port, $path, $query, $fragment) {
|
||||||
$uri = new HTMLPurifier_URI($scheme, $userinfo, $host, $port, $path, $query, $fragment);
|
$uri = new HTMLPurifier_URI($scheme, $userinfo, $host, $port, $path, $query, $fragment);
|
||||||
$string = $uri->toString();
|
$string = $uri->toString();
|
||||||
$this->assertIdentical($string, $expect_uri);
|
$this->assertIdentical($string, $expect_uri);
|
||||||
@ -136,7 +136,7 @@ class HTMLPurifier_URITest extends HTMLPurifier_URIHarness
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function assertValidation($uri, $expect_uri = true) {
|
protected function assertValidation($uri, $expect_uri = true) {
|
||||||
if ($expect_uri === true) $expect_uri = $uri;
|
if ($expect_uri === true) $expect_uri = $uri;
|
||||||
$uri = $this->createURI($uri);
|
$uri = $this->createURI($uri);
|
||||||
$result = $uri->validate($this->config, $this->context);
|
$result = $uri->validate($this->config, $this->context);
|
||||||
|
@ -10,7 +10,7 @@ class PHPT_Controller_SimpleTest extends SimpleTestCase
|
|||||||
|
|
||||||
public function __construct($path) {
|
public function __construct($path) {
|
||||||
$this->_path = $path;
|
$this->_path = $path;
|
||||||
parent::SimpleTestCase($path);
|
parent::__construct($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testPhpt() {
|
public function testPhpt() {
|
||||||
|
Loading…
Reference in New Issue
Block a user