1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-08-05 13:47:24 +02:00

Refactor validators so that they can be reused between directives and namespaces.

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1589 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang
2008-03-02 04:39:14 +00:00
parent 18320d59a4
commit d8cb360f3b
12 changed files with 131 additions and 71 deletions

View File

@@ -0,0 +1,17 @@
<?php
class HTMLPurifier_ConfigSchema_Validator_AlnumTest extends HTMLPurifier_ConfigSchema_ValidatorHarness
{
public function setup() {
parent::setup();
$this->validator = new HTMLPurifier_ConfigSchema_Validator_Alnum('ID');
}
public function testValidate() {
$this->expectSchemaException('R&D in ID must be alphanumeric');
$arr = array('ID' => 'R&D');
$this->validator->validate($arr, $this->interchange);
}
}

View File

@@ -0,0 +1,17 @@
<?php
class HTMLPurifier_ConfigSchema_Validator_ExistsTest extends HTMLPurifier_ConfigSchema_ValidatorHarness
{
public function setup() {
parent::setup();
$this->validator = new HTMLPurifier_ConfigSchema_Validator_Exists('ID');
}
public function testValidate() {
$this->expectSchemaException('ID must exist');
$arr = array();
$this->validator->validate($arr, $this->interchange);
}
}

View File

@@ -1,23 +0,0 @@
<?php
class HTMLPurifier_ConfigSchema_Validator_IdExistsTest extends HTMLPurifier_ConfigSchema_ValidatorHarness
{
public function setup() {
parent::setup();
$this->validator = new HTMLPurifier_ConfigSchema_Validator_IdExists();
}
public function testValidateNamespace() {
$this->expectSchemaException('ID must exist in namespace');
$arr = array();
$this->validator->validateNamespace($arr, $this->interchange);
}
public function testValidateDirective() {
$this->expectSchemaException('ID must exist in directive');
$arr = array();
$this->validator->validateDirective($arr, $this->interchange);
}
}