mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-08-01 11:50:28 +02:00
[3.1.0] Implement ConfigSchema interchange
- Implement exception hierarchy git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1582 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
44
tests/HTMLPurifier/ConfigSchema/InterchangeTest.php
Normal file
44
tests/HTMLPurifier/ConfigSchema/InterchangeTest.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
class HTMLPurifier_ConfigSchema_InterchangeTest extends UnitTestCase
|
||||
{
|
||||
|
||||
protected $interchange;
|
||||
|
||||
public function setup() {
|
||||
$this->interchange = new HTMLPurifier_ConfigSchema_Interchange();
|
||||
}
|
||||
|
||||
public function testAddNamespace() {
|
||||
$this->interchange->addNamespace($v = array(
|
||||
'ID' => 'Namespace',
|
||||
'Foo' => 'Bar',
|
||||
));
|
||||
$this->assertIdentical($v, $this->interchange->namespaces['Namespace']);
|
||||
}
|
||||
|
||||
public function testAddNamespaceError() {
|
||||
try {
|
||||
$this->interchange->addNamespace(array());
|
||||
} catch (HTMLPurifier_ConfigSchema_Exception $e) {
|
||||
$this->assertIdentical($e->getMessage(), 'Namespace must have ID');
|
||||
}
|
||||
}
|
||||
|
||||
public function testAddDirective() {
|
||||
$this->interchange->addDirective($v = array(
|
||||
'ID' => 'Namespace.Directive',
|
||||
'Foo' => 'Bar',
|
||||
));
|
||||
$this->assertIdentical($v, $this->interchange->directives['Namespace.Directive']);
|
||||
}
|
||||
|
||||
public function testAddDirectiveError() {
|
||||
try {
|
||||
$this->interchange->addDirective(array());
|
||||
} catch (HTMLPurifier_ConfigSchema_Exception $e) {
|
||||
$this->assertIdentical($e->getMessage(), 'Directive must have ID');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -52,4 +52,12 @@ class HTMLPurifier_ConfigSchema_StringHashParserTest extends UnitTestCase
|
||||
));
|
||||
}
|
||||
|
||||
function testError() {
|
||||
try {
|
||||
$this->parser->parseFile('NoExist.txt');
|
||||
} catch (HTMLPurifier_ConfigSchema_Exception $e) {
|
||||
$this->assertIdentical($e->getMessage(), 'File NoExist.txt does not exist');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user