1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-07-31 03:10:09 +02:00

[1.2.0] Unit test housekeeping:

- HTMLPurifier_Context doesn't throw a variable reference error if you attempt to retrieve a non-existent variable
. Cleaned up test-cases to remove unnecessary swallowErrors()

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@525 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang
2006-11-16 23:58:33 +00:00
parent d48f9b6b21
commit 2dc8e9c3d5
5 changed files with 10 additions and 19 deletions

View File

@@ -77,7 +77,6 @@ class HTMLPurifier_ConfigSchemaTest extends UnitTestCase
);
$this->assertError('Cannot define directive for undefined namespace');
$this->assertNoErrors();
$this->swallowErrors();
@@ -104,7 +103,6 @@ class HTMLPurifier_ConfigSchemaTest extends UnitTestCase
);
$this->assertError('Inconsistent default or type, cannot redefine');
$this->assertNoErrors();
$this->swallowErrors();
@@ -150,7 +148,6 @@ class HTMLPurifier_ConfigSchemaTest extends UnitTestCase
);
$this->assertError('Cannot define allowed values for undefined directive');
$this->assertNoErrors();
$this->swallowErrors();
@@ -192,7 +189,6 @@ class HTMLPurifier_ConfigSchemaTest extends UnitTestCase
);
$this->assertError('Cannot define alias to value that is not allowed');
$this->assertNoErrors();
$this->swallowErrors();
@@ -204,7 +200,6 @@ class HTMLPurifier_ConfigSchemaTest extends UnitTestCase
);
$this->assertError('Cannot define alias over allowed value');
$this->assertNoErrors();
$this->swallowErrors();
@@ -216,7 +211,6 @@ class HTMLPurifier_ConfigSchemaTest extends UnitTestCase
$this->assertError('Invalid type for configuration directive');
$this->assertNoErrors();
$this->swallowErrors();
@@ -228,7 +222,6 @@ class HTMLPurifier_ConfigSchemaTest extends UnitTestCase
$this->assertError('Default value does not match directive type');
$this->assertNoErrors();
$this->swallowErrors();
@@ -239,7 +232,6 @@ class HTMLPurifier_ConfigSchemaTest extends UnitTestCase
);
$this->assertNoErrors();
$this->swallowErrors();
// define a directive with bad characters
@@ -250,7 +242,6 @@ class HTMLPurifier_ConfigSchemaTest extends UnitTestCase
$this->assertError('Directive name must be alphanumeric');
$this->assertNoErrors();
$this->swallowErrors();
// define a namespace with bad characters
HTMLPurifier_ConfigSchema::defineNamespace(
@@ -259,7 +250,6 @@ class HTMLPurifier_ConfigSchemaTest extends UnitTestCase
$this->assertError('Namespace name must be alphanumeric');
$this->assertNoErrors();
$this->swallowErrors();
}

View File

@@ -66,25 +66,21 @@ class HTMLPurifier_ConfigTest extends UnitTestCase
$config->get('Core', 'NotDefined');
$this->assertError('Cannot retrieve value of undefined directive');
$this->assertNoErrors();
$this->swallowErrors();
// try to set undefined value
$config->set('Foobar', 'Key', 'foobar');
$this->assertError('Cannot set undefined directive to value');
$this->assertNoErrors();
$this->swallowErrors();
// try to set not allowed value
$config->set('Extension', 'Pert', 'wizard');
$this->assertError('Value not supported');
$this->assertNoErrors();
$this->swallowErrors();
// try to set not allowed value
$config->set('Extension', 'Pert', 34);
$this->assertError('Value is of invalid type');
$this->assertNoErrors();
$this->swallowErrors();
// set aliased value
$config->set('Extension', 'Pert', 'cow');
@@ -109,12 +105,16 @@ class HTMLPurifier_ConfigTest extends UnitTestCase
$config->set('Extension', 'Pert', null);
$this->assertError('Value is of invalid type');
$this->assertNoErrors();
$this->swallowErrors();
}
function test_getDefinition() {
// we actually want to use the old copy, because the definition
// generation routines have dependencies on configuration values
$this->old_copy = HTMLPurifier_ConfigSchema::instance($this->old_copy);
$config = HTMLPurifier_Config::createDefault();
$def = $config->getHTMLDefinition();
$this->assertIsA($def, 'HTMLPurifier_HTMLDefinition');

View File

@@ -32,11 +32,9 @@ class HTMLPurifier_ContextTest extends UnitTestCase
$accumulator_3 =& $this->context->get('IDAccumulator');
$this->assertError('Attempted to retrieve non-existent variable');
$this->assertNull($accumulator_3);
$this->swallowErrors();
$this->context->destroy('IDAccumulator');
$this->assertError('Attempted to destroy non-existent variable');
$this->swallowErrors();
}
@@ -48,7 +46,6 @@ class HTMLPurifier_ContextTest extends UnitTestCase
$this->context->register('OnceOnly', $var);
$this->assertError('Name collision, cannot re-register');
$this->swallowErrors();
// destroy it, now registration is okay
$this->context->destroy('OnceOnly');