0
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2024-11-09 15:28:40 +00: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

3
NEWS
View File

@ -24,11 +24,14 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier
+ Updated code-quality.txt, removing issues that have been resolved
+ Improved inline comments in AttrDef/Class.php, AttrDef/CSS.php
and AttrDef/Host.php
- HTMLPurifier_Context doesn't throw a variable reference error if you attempt
to retrieve a non-existent variable
. Switched to purify()-wide Context object registry
. Refactored unit tests to minimize duplication
. XSS attack sheet updated
. configdoc.xml now has xml:space attached to default value nodes
. Allow configuration directives to permit null values
. Cleaned up test-cases to remove unnecessary swallowErrors()
1.1.3, unknown projected release date
(bugfix release, may be dropped if no major bugs are found before features)

View File

@ -34,7 +34,8 @@ class HTMLPurifier_Context
if (!isset($this->_storage[$name])) {
trigger_error('Attempted to retrieve non-existent variable',
E_USER_ERROR);
return;
$var = null; // so we can return by reference
return $var;
}
return $this->_storage[$name];
}

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');