1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-08-05 21:57:26 +02:00

Remove trailing whitespace.

Signed-off-by: Edward Z. Yang <edwardzyang@thewritingpot.com>
This commit is contained in:
Edward Z. Yang
2008-12-06 02:28:20 -05:00
parent 3a6b63dff1
commit 2c955af135
476 changed files with 5595 additions and 5547 deletions

View File

@@ -2,25 +2,25 @@
class HTMLPurifier_ConfigSchema_InterchangeTest extends UnitTestCase
{
protected $interchange;
public function setup() {
$this->interchange = new HTMLPurifier_ConfigSchema_Interchange();
}
function testAddNamespace() {
$v = new HTMLPurifier_ConfigSchema_Interchange_Namespace();
$v->namespace = 'Namespace';
$this->interchange->addNamespace($v);
$this->assertIdentical($v, $this->interchange->namespaces['Namespace']);
}
function testAddDirective() {
$v = new HTMLPurifier_ConfigSchema_Interchange_Directive();
$v->id = new HTMLPurifier_ConfigSchema_Interchange_Id('Namespace', 'Directive');
$this->interchange->addDirective($v);
$this->assertIdentical($v, $this->interchange->directives['Namespace.Directive']);
}
}

View File

@@ -7,4 +7,4 @@ ID: Ns.Dir
TYPE: string
DESCRIPTION: Description
DEFAULT: 'asdf'
ALLOWED:
ALLOWED:

View File

@@ -2,87 +2,87 @@
class HTMLPurifier_ConfigSchema_ValidatorAtomTest extends UnitTestCase
{
protected function expectValidationException($msg) {
$this->expectException(new HTMLPurifier_ConfigSchema_Exception($msg));
}
protected function makeAtom($value) {
$obj = new stdClass();
$obj->property = $value;
// Note that 'property' and 'context' are magic wildcard values
return new HTMLPurifier_ConfigSchema_ValidatorAtom('context', $obj, 'property');
}
function testAssertIsString() {
$this->makeAtom('foo')->assertIsString();
}
function testAssertIsStringFail() {
$this->expectValidationException("Property in context must be a string");
$this->makeAtom(3)->assertIsString();
}
function testAssertNotNull() {
$this->makeAtom('foo')->assertNotNull();
}
function testAssertNotNullFail() {
$this->expectValidationException("Property in context must not be null");
$this->makeAtom(null)->assertNotNull();
}
function testAssertAlnum() {
$this->makeAtom('foo2')->assertAlnum();
}
function testAssertAlnumFail() {
$this->expectValidationException("Property in context must be alphanumeric");
$this->makeAtom('%a')->assertAlnum();
}
function testAssertAlnumFailIsString() {
$this->expectValidationException("Property in context must be a string");
$this->makeAtom(3)->assertAlnum();
}
function testAssertNotEmpty() {
$this->makeAtom('foo')->assertNotEmpty();
}
function testAssertNotEmptyFail() {
$this->expectValidationException("Property in context must not be empty");
$this->makeAtom('')->assertNotEmpty();
}
function testAssertIsBool() {
$this->makeAtom(false)->assertIsBool();
}
function testAssertIsBoolFail() {
$this->expectValidationException("Property in context must be a boolean");
$this->makeAtom('0')->assertIsBool();
}
function testAssertIsArray() {
$this->makeAtom(array())->assertIsArray();
}
function testAssertIsArrayFail() {
$this->expectValidationException("Property in context must be an array");
$this->makeAtom('asdf')->assertIsArray();
}
function testAssertIsLookup() {
$this->makeAtom(array('foo' => true))->assertIsLookup();
}
function testAssertIsLookupFail() {
$this->expectValidationException("Property in context must be a lookup array");
$this->makeAtom(array('foo' => 4))->assertIsLookup();
}
function testAssertIsLookupFailIsArray() {
$this->expectValidationException("Property in context must be an array");
$this->makeAtom('asdf')->assertIsLookup();

View File

@@ -7,71 +7,71 @@
class HTMLPurifier_ConfigSchema_ValidatorTest extends UnitTestCase
{
public $validator, $interchange;
public function setup() {
$this->validator = new HTMLPurifier_ConfigSchema_Validator();
$this->interchange = new HTMLPurifier_ConfigSchema_Interchange();
}
function testNamespaceIntegrityViolation() {
$ns = $this->makeNamespace('Ns');
$ns->namespace = 'AltNs';
$this->expectValidationException("Integrity violation: key 'Ns' does not match internal id 'AltNs'");
$this->validator->validate($this->interchange);
}
function testNamespaceNamespaceIsString() {
$this->makeNamespace(3);
$this->expectValidationException("Namespace in namespace '3' must be a string");
$this->validator->validate($this->interchange);
}
function testNamespaceDescriptionIsString() {
$ns = $this->makeNamespace('Ns');
$ns->description = 3;
$this->expectValidationException("Description in namespace 'Ns' must be a string");
$this->validator->validate($this->interchange);
}
function testDirectiveIntegrityViolation() {
$d = $this->makeDirective('Ns', 'Dir');
$d->id = new HTMLPurifier_ConfigSchema_Interchange_Id('Ns', 'Dir2');
$this->expectValidationException("Integrity violation: key 'Ns.Dir' does not match internal id 'Ns.Dir2'");
$this->validator->validate($this->interchange);
}
function testDirectiveTypeNotEmpty() {
$this->makeNamespace('Ns');
$d = $this->makeDirective('Ns', 'Dir');
$d->default = 0;
$d->description = 'Description';
$this->expectValidationException("Type in directive 'Ns.Dir' must not be empty");
$this->validator->validate($this->interchange);
}
function testDirectiveDefaultInvalid() {
$this->makeNamespace('Ns');
$d = $this->makeDirective('Ns', 'Dir');
$d->default = 'asdf';
$d->type = 'int';
$d->description = 'Description';
$this->expectValidationException("Default in directive 'Ns.Dir' had error: Expected type int, got string");
$this->validator->validate($this->interchange);
}
function testDirectiveIdDirectiveIsString() {
$this->makeNamespace('Ns');
$d = $this->makeDirective('Ns', 3);
$d->default = 0;
$d->type = 'int';
$d->description = 'Description';
$this->expectValidationException("Directive in id 'Ns.3' in directive 'Ns.3' must be a string");
$this->validator->validate($this->interchange);
}
function testDirectiveTypeAllowsNullIsBool() {
$this->makeNamespace('Ns');
$d = $this->makeDirective('Ns', 'Dir');
@@ -79,11 +79,11 @@ class HTMLPurifier_ConfigSchema_ValidatorTest extends UnitTestCase
$d->type = 'int';
$d->description = 'Description';
$d->typeAllowsNull = 'yes';
$this->expectValidationException("TypeAllowsNull in directive 'Ns.Dir' must be a boolean");
$this->validator->validate($this->interchange);
}
function testDirectiveValueAliasesIsArray() {
$this->makeNamespace('Ns');
$d = $this->makeDirective('Ns', 'Dir');
@@ -91,11 +91,11 @@ class HTMLPurifier_ConfigSchema_ValidatorTest extends UnitTestCase
$d->type = 'string';
$d->description = 'Description';
$d->valueAliases = 2;
$this->expectValidationException("ValueAliases in directive 'Ns.Dir' must be an array");
$this->validator->validate($this->interchange);
}
function testDirectiveAllowedIsLookup() {
$this->makeNamespace('Ns');
$d = $this->makeDirective('Ns', 'Dir');
@@ -103,13 +103,13 @@ class HTMLPurifier_ConfigSchema_ValidatorTest extends UnitTestCase
$d->type = 'string';
$d->description = 'Description';
$d->allowed = array('foo' => 1);
$this->expectValidationException("Allowed in directive 'Ns.Dir' must be a lookup array");
$this->validator->validate($this->interchange);
}
// helper functions
protected function makeNamespace($n) {
$namespace = new HTMLPurifier_ConfigSchema_Interchange_Namespace();
$namespace->namespace = $n;
@@ -117,16 +117,16 @@ class HTMLPurifier_ConfigSchema_ValidatorTest extends UnitTestCase
$this->interchange->addNamespace($namespace);
return $namespace;
}
protected function makeDirective($n, $d) {
$directive = new HTMLPurifier_ConfigSchema_Interchange_Directive();
$directive->id = new HTMLPurifier_ConfigSchema_Interchange_Id($n, $d);
$this->interchange->addDirective($directive);
return $directive;
}
protected function expectValidationException($msg) {
$this->expectException(new HTMLPurifier_ConfigSchema_Exception($msg));
}
}

View File

@@ -5,21 +5,21 @@
*/
class HTMLPurifier_ConfigSchema_ValidatorTestCase extends UnitTestCase
{
protected $_path, $_parser, $_builder;
public $validator;
public function __construct($path) {
$this->_path = $path;
$this->_parser = new HTMLPurifier_StringHashParser();
$this->_builder = new HTMLPurifier_ConfigSchema_InterchangeBuilder();
parent::__construct($path);
}
public function setup() {
$this->validator = new HTMLPurifier_ConfigSchema_Validator();
}
function testValidator() {
$hashes = $this->_parser->parseMultiFile($this->_path);
$interchange = new HTMLPurifier_ConfigSchema_Interchange();
@@ -38,5 +38,5 @@ class HTMLPurifier_ConfigSchema_ValidatorTestCase extends UnitTestCase
$this->validator->validate($interchange);
$this->pass();
}
}