diff options
Diffstat (limited to 'lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema')
23 files changed, 0 insertions, 396 deletions
diff --git a/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/InterchangeTest.php b/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/InterchangeTest.php deleted file mode 100644 index 0d539ea2c..000000000 --- a/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/InterchangeTest.php +++ /dev/null @@ -1,21 +0,0 @@ -<?php - -class HTMLPurifier_ConfigSchema_InterchangeTest extends UnitTestCase -{ - - protected $interchange; - - public function setup() { - $this->interchange = new HTMLPurifier_ConfigSchema_Interchange(); - } - - 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']); - } - -} - -// vim: et sw=4 sts=4 diff --git a/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/aliasesAliasCollision.vtest b/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/aliasesAliasCollision.vtest deleted file mode 100644 index ed3857c40..000000000 --- a/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/aliasesAliasCollision.vtest +++ /dev/null @@ -1,13 +0,0 @@ -ERROR: Alias 'Ns.BothWantThisName' in aliases in directive 'Ns.Dir2' collides with alias for directive 'Ns.Dir' ----- -Ns.Dir -DESCRIPTION: Directive -TYPE: int -DEFAULT: 3 -ALIASES: Ns.BothWantThisName ----- -Ns.Dir2 -DESCRIPTION: Directive -TYPE: string -DEFAULT: 'a' -ALIASES: Ns.BothWantThisName diff --git a/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/aliasesDirectiveCollision.vtest b/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/aliasesDirectiveCollision.vtest deleted file mode 100644 index 582a481a4..000000000 --- a/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/aliasesDirectiveCollision.vtest +++ /dev/null @@ -1,12 +0,0 @@ -ERROR: Alias 'Ns.Innocent' in aliases in directive 'Ns.Dir' collides with another directive ----- -Ns.Innocent -DESCRIPTION: Innocent directive -TYPE: int -DEFAULT: 3 ----- -Ns.Dir -DESCRIPTION: Directive -TYPE: string -DEFAULT: 'a' -ALIASES: Ns.Innocent diff --git a/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/allowedIsString.vtest b/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/allowedIsString.vtest deleted file mode 100644 index 9ecc5f930..000000000 --- a/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/allowedIsString.vtest +++ /dev/null @@ -1,7 +0,0 @@ -ERROR: Value 3 in allowed in directive 'Ns.Dir' must be a string ----- -ID: Ns.Dir -TYPE: string -DESCRIPTION: Description -DEFAULT: 'asdf' -ALLOWED: 'asdf', 3 diff --git a/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/allowedNotEmpty.vtest b/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/allowedNotEmpty.vtest deleted file mode 100644 index 1e08fab0d..000000000 --- a/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/allowedNotEmpty.vtest +++ /dev/null @@ -1,7 +0,0 @@ -ERROR: Allowed in directive 'Ns.Dir' must not be empty ----- -ID: Ns.Dir -TYPE: string -DESCRIPTION: Description -DEFAULT: 'asdf' -ALLOWED: diff --git a/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/defaultIsAllowed.vtest b/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/defaultIsAllowed.vtest deleted file mode 100644 index ef1944707..000000000 --- a/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/defaultIsAllowed.vtest +++ /dev/null @@ -1,7 +0,0 @@ -ERROR: Default in directive 'Ns.Dir' must be an allowed value ----- -Ns.Dir -DESCRIPTION: Directive -TYPE: string -DEFAULT: 'a' -ALLOWED: 'b' diff --git a/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/defaultNullWithAllowed.vtest b/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/defaultNullWithAllowed.vtest deleted file mode 100644 index 7ba3c85c0..000000000 --- a/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/defaultNullWithAllowed.vtest +++ /dev/null @@ -1,5 +0,0 @@ -Ns.Dir -DESCRIPTION: Directive -TYPE: string/null -DEFAULT: null -ALLOWED: 'a' diff --git a/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/defaultType.vtest b/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/defaultType.vtest deleted file mode 100644 index 79ea043ac..000000000 --- a/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/defaultType.vtest +++ /dev/null @@ -1,6 +0,0 @@ -ERROR: Expected type string, got integer in DEFAULT in directive hash 'Ns.Dir' ----- -Ns.Dir -DESCRIPTION: Directive -TYPE: string -DEFAULT: 0 diff --git a/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/descriptionNotEmpty.vtest b/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/descriptionNotEmpty.vtest deleted file mode 100644 index d09ddc77b..000000000 --- a/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/descriptionNotEmpty.vtest +++ /dev/null @@ -1,5 +0,0 @@ -ERROR: Description in directive 'Ns.Dir' must not be empty ----- -Ns.Dir -TYPE: int -DEFAULT: 0 diff --git a/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/ignoreNamespace.vtest b/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/ignoreNamespace.vtest deleted file mode 100644 index 3fc28d3a4..000000000 --- a/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/ignoreNamespace.vtest +++ /dev/null @@ -1,3 +0,0 @@ -Ns -DESCRIPTION: Namespace - diff --git a/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/typeDefined.vtest b/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/typeDefined.vtest deleted file mode 100644 index 4bb8abeb2..000000000 --- a/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/typeDefined.vtest +++ /dev/null @@ -1,5 +0,0 @@ -ERROR: TYPE in directive hash 'Ns.Dir' not defined ----- -Ns.Dir -DESCRIPTION: Notice that TYPE is missing -DEFAULT: 0 diff --git a/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/typeExists.vtest b/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/typeExists.vtest deleted file mode 100644 index f9851f536..000000000 --- a/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/typeExists.vtest +++ /dev/null @@ -1,6 +0,0 @@ -ERROR: Invalid type 'foobar' in DEFAULT in directive hash 'Ns.Dir' ----- -Ns.Dir -DESCRIPTION: Directive -TYPE: foobar -DEFAULT: 0 diff --git a/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/typeWithAllowedIsStringType.vtest b/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/typeWithAllowedIsStringType.vtest deleted file mode 100644 index bf4e2b21b..000000000 --- a/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/typeWithAllowedIsStringType.vtest +++ /dev/null @@ -1,7 +0,0 @@ -ERROR: Type in directive 'Ns.Dir' must be a string type when used with allowed or value aliases ----- -Ns.Dir -DESCRIPTION: Directive -TYPE: int -DEFAULT: 3 -ALLOWED: 1, 2, 3 diff --git a/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/typeWithValueAliasesIsStringType.vtest b/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/typeWithValueAliasesIsStringType.vtest deleted file mode 100644 index 59cf4333a..000000000 --- a/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/typeWithValueAliasesIsStringType.vtest +++ /dev/null @@ -1,7 +0,0 @@ -ERROR: Type in directive 'Ns.Dir' must be a string type when used with allowed or value aliases ----- -Ns.Dir -DESCRIPTION: Directive -TYPE: int -DEFAULT: 3 -VALUE-ALIASES: 2 => 3 diff --git a/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/unique.vtest b/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/unique.vtest deleted file mode 100644 index c83649e8d..000000000 --- a/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/unique.vtest +++ /dev/null @@ -1,11 +0,0 @@ -ERROR: Cannot redefine directive 'Ns.Dir' ----- -ID: Ns.Dir -DESCRIPTION: Version 1 -TYPE: int -DEFAULT: 0 ----- -ID: Ns.Dir -DESCRIPTION: Version 2 -TYPE: int -DEFAULT: 0 diff --git a/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/valueAliasesAliasIsString.vtest b/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/valueAliasesAliasIsString.vtest deleted file mode 100644 index b9f28eee1..000000000 --- a/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/valueAliasesAliasIsString.vtest +++ /dev/null @@ -1,7 +0,0 @@ -ERROR: Alias 3 in valueAliases in directive 'Ns.Dir' must be a string ----- -Ns.Dir -DESCRIPTION: Directive -TYPE: string -DEFAULT: 'a' -VALUE-ALIASES: 3 => 'a' diff --git a/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/valueAliasesAliasNotAllowed.vtest b/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/valueAliasesAliasNotAllowed.vtest deleted file mode 100644 index ef9c14883..000000000 --- a/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/valueAliasesAliasNotAllowed.vtest +++ /dev/null @@ -1,8 +0,0 @@ -ERROR: Alias 'b' in valueAliases in directive 'Ns.Dir' must not be an allowed value ----- -Ns.Dir -DESCRIPTION: Directive -TYPE: string -DEFAULT: 'a' -ALLOWED: 'a', 'b', 'c' -VALUE-ALIASES: 'b' => 'c' diff --git a/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/valueAliasesNotAliasSelf.vtest b/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/valueAliasesNotAliasSelf.vtest deleted file mode 100644 index 4c417fd5f..000000000 --- a/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/valueAliasesNotAliasSelf.vtest +++ /dev/null @@ -1,7 +0,0 @@ -ERROR: Alias 'bar' in valueAliases in directive 'Ns.Dir' must not be an alias to itself ----- -Ns.Dir -DESCRIPTION: Directive -TYPE: string -DEFAULT: 'foo' -VALUE-ALIASES: 'bar' => 'bar' diff --git a/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/valueAliasesRealAllowed.vtest b/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/valueAliasesRealAllowed.vtest deleted file mode 100644 index 89502d34a..000000000 --- a/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/valueAliasesRealAllowed.vtest +++ /dev/null @@ -1,8 +0,0 @@ -ERROR: Alias 'c' in valueAliases in directive 'Ns.Dir' must be an alias to an allowed value ----- -Ns.Dir -DESCRIPTION: Directive -TYPE: string -DEFAULT: 'a' -ALLOWED: 'a', 'b' -VALUE-ALIASES: 'c' => 'd' diff --git a/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/valueAliasesRealIsString.vtest b/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/valueAliasesRealIsString.vtest deleted file mode 100644 index 92ec197dc..000000000 --- a/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/Validator/directive/valueAliasesRealIsString.vtest +++ /dev/null @@ -1,7 +0,0 @@ -ERROR: Alias target 3 from alias 'b' in valueAliases in directive 'Ns.Dir' must be a string ----- -Ns.Dir -DESCRIPTION: Directive -TYPE: string -DEFAULT: 'a' -VALUE-ALIASES: 'b' => 3 diff --git a/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/ValidatorAtomTest.php b/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/ValidatorAtomTest.php deleted file mode 100644 index 38625136e..000000000 --- a/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/ValidatorAtomTest.php +++ /dev/null @@ -1,92 +0,0 @@ -<?php - -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(); - } -} - -// vim: et sw=4 sts=4 diff --git a/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/ValidatorTest.php b/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/ValidatorTest.php deleted file mode 100644 index 9cbf36e2d..000000000 --- a/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/ValidatorTest.php +++ /dev/null @@ -1,101 +0,0 @@ -<?php - -/** - * Special test-case for cases that can't be tested using - * HTMLPurifier_ConfigSchema_ValidatorTestCase. - */ -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 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() { - $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() { - $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 testDirectiveIdIsString() { - $d = $this->makeDirective(3); - $d->default = 0; - $d->type = 'int'; - $d->description = 'Description'; - - $this->expectValidationException("Key in id '3' in directive '3' must be a string"); - $this->validator->validate($this->interchange); - } - - function testDirectiveTypeAllowsNullIsBool() { - $d = $this->makeDirective('Ns.Dir'); - $d->default = 0; - $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() { - $d = $this->makeDirective('Ns.Dir'); - $d->default = 'a'; - $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() { - $d = $this->makeDirective('Ns.Dir'); - $d->default = 'foo'; - $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 makeDirective($key) { - $directive = new HTMLPurifier_ConfigSchema_Interchange_Directive(); - $directive->id = new HTMLPurifier_ConfigSchema_Interchange_Id($key); - $this->interchange->addDirective($directive); - return $directive; - } - - protected function expectValidationException($msg) { - $this->expectException(new HTMLPurifier_ConfigSchema_Exception($msg)); - } - -} - -// vim: et sw=4 sts=4 diff --git a/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/ValidatorTestCase.php b/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/ValidatorTestCase.php deleted file mode 100644 index 87fa14d0d..000000000 --- a/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchema/ValidatorTestCase.php +++ /dev/null @@ -1,44 +0,0 @@ -<?php - -/** - * Controller for validator test-cases. - */ -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(); - $error = null; - foreach ($hashes as $hash) { - if (!isset($hash['ID'])) { - if (isset($hash['ERROR'])) { - $this->expectException( - new HTMLPurifier_ConfigSchema_Exception($hash['ERROR']) - ); - } - continue; - } - $this->_builder->build($interchange, new HTMLPurifier_StringHash($hash)); - } - $this->validator->validate($interchange); - $this->pass(); - } - -} - -// vim: et sw=4 sts=4 |