0
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2024-09-19 18:55:19 +00:00

Migrate from assertError to expectError, removed all assertNoErrors()

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@669 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang 2007-01-20 19:22:55 +00:00
parent 5e366b25f8
commit 108df87824
6 changed files with 25 additions and 52 deletions

View File

@ -66,13 +66,11 @@ class HTMLPurifier_AttrDef_IDTest extends HTMLPurifier_AttrDefHarness
$this->assertDef('user_story95_alas');
$this->assertDef('user_alas', 'user_story95_user_alas'); // !
// no effect when IDPrefix isn't set
$this->config->set('Attr', 'IDPrefix', '');
$this->assertDef('amherst'); // no affect when IDPrefix isn't set
$this->assertError('%Attr.IDPrefixLocal cannot be used unless '.
$this->expectError('%Attr.IDPrefixLocal cannot be used unless '.
'%Attr.IDPrefix is set');
// SimpleTest has a bug and throws a sprintf error
// $this->assertNoErrors();
$this->swallowErrors();
$this->assertDef('amherst');
}

View File

@ -38,10 +38,9 @@ extends HTMLPurifier_ChildDefHarness
$this->assertResult('Needs wrap', '<div>Needs wrap</div>',
array('HTML.BlockWrapper' => 'div'));
$this->expectError('Cannot use non-block element as block wrapper.');
$this->assertResult('Needs wrap', '<p>Needs wrap</p>',
array('HTML.BlockWrapper' => 'dav'));
$this->assertError('Cannot use non-block element as block wrapper.');
$this->assertNoErrors();
}

View File

@ -71,12 +71,11 @@ class HTMLPurifier_ConfigSchemaTest extends UnitTestCase
// define a directive in an undefined namespace
$this->expectError('Cannot define directive for undefined namespace');
HTMLPurifier_ConfigSchema::define(
'Extension', 'Name', false, 'bool',
'This is for an extension, but we have not defined its namespace!'
);
$this->assertError('Cannot define directive for undefined namespace');
$this->assertNoErrors();
@ -86,7 +85,7 @@ class HTMLPurifier_ConfigSchemaTest extends UnitTestCase
'Core', 'Name', 'default value', 'string',
$description
); $line = __LINE__;
$this->assertNoErrors();
$directive->addDescription($file, $line, $description);
$this->assertIdentical($this->our_copy->info, array(
'Core' => array(
@ -97,12 +96,11 @@ class HTMLPurifier_ConfigSchemaTest extends UnitTestCase
// redefine a directive in an invalid manner
$this->expectError('Inconsistent default or type, cannot redefine');
HTMLPurifier_ConfigSchema::define(
'Core', 'Name', 'different default', 'string',
'Inconsistent default or type, cannot redefine'
);
$this->assertError('Inconsistent default or type, cannot redefine');
$this->assertNoErrors();
@ -141,13 +139,12 @@ class HTMLPurifier_ConfigSchemaTest extends UnitTestCase
// cannot define enumeration for undefined directive
$this->expectError('Cannot define allowed values for undefined directive');
HTMLPurifier_ConfigSchema::defineAllowedValues(
'Core', 'Foobar', array(
'Real Value 9',
)
);
$this->assertError('Cannot define allowed values for undefined directive');
$this->assertNoErrors();
@ -182,47 +179,41 @@ class HTMLPurifier_ConfigSchemaTest extends UnitTestCase
// cannot create alias to not-allowed value
$this->expectError('Cannot define alias to value that is not allowed');
HTMLPurifier_ConfigSchema::defineValueAliases(
'Core', 'Name', array(
'Aliased Value 3' => 'Invalid Value'
)
);
$this->assertError('Cannot define alias to value that is not allowed');
$this->assertNoErrors();
// cannot create alias for already allowed value
$this->expectError('Cannot define alias over allowed value');
HTMLPurifier_ConfigSchema::defineValueAliases(
'Core', 'Name', array(
'Real Value' => 'Real Value 2'
)
);
$this->assertError('Cannot define alias over allowed value');
$this->assertNoErrors();
// define a directive with an invalid type
$this->expectError('Invalid type for configuration directive');
HTMLPurifier_ConfigSchema::define(
'Core', 'Foobar', false, 'omen',
'Omen is not a valid type, so we reject this.'
);
$this->assertError('Invalid type for configuration directive');
$this->assertNoErrors();
// define a directive with inconsistent type
$this->expectError('Default value does not match directive type');
HTMLPurifier_ConfigSchema::define(
'Core', 'Foobaz', 10, 'string',
'If we say string, we should mean it, not integer 10.'
);
$this->assertError('Default value does not match directive type');
$this->assertNoErrors();
// define a directive that allows null
@ -231,25 +222,22 @@ class HTMLPurifier_ConfigSchemaTest extends UnitTestCase
'Nulls are allowed if you add on /null, cool huh?'
);
$this->assertNoErrors();
// define a directive with bad characters
$this->expectError('Directive name must be alphanumeric');
HTMLPurifier_ConfigSchema::define(
'Core', 'Core.Attr', 10, 'int',
'No periods! >:-('
);
$this->assertError('Directive name must be alphanumeric');
$this->assertNoErrors();
// define a namespace with bad characters
$this->expectError('Namespace name must be alphanumeric');
HTMLPurifier_ConfigSchema::defineNamespace(
'Foobar&Gromit', $description
);
$this->assertError('Namespace name must be alphanumeric');
$this->assertNoErrors();
// alias related tests

View File

@ -63,48 +63,39 @@ class HTMLPurifier_ConfigTest extends UnitTestCase
$this->assertIdentical($config->get('Core', 'Key'), true);
// try to retrieve undefined value
$this->expectError('Cannot retrieve value of undefined directive');
$config->get('Core', 'NotDefined');
$this->assertError('Cannot retrieve value of undefined directive');
$this->assertNoErrors();
// try to set undefined value
$this->expectError('Cannot set undefined directive to value');
$config->set('Foobar', 'Key', 'foobar');
$this->assertError('Cannot set undefined directive to value');
$this->assertNoErrors();
// try to set not allowed value
$this->expectError('Value not supported');
$config->set('Extension', 'Pert', 'wizard');
$this->assertError('Value not supported');
$this->assertNoErrors();
// try to set not allowed value
$this->expectError('Value is of invalid type');
$config->set('Extension', 'Pert', 34);
$this->assertError('Value is of invalid type');
$this->assertNoErrors();
// set aliased value
$config->set('Extension', 'Pert', 'cow');
$this->assertNoErrors();
$this->assertIdentical($config->get('Extension', 'Pert'), 'moo');
// case-insensitive attempt to set value that is allowed
$config->set('Core', 'Encoding', 'ISO-8859-1');
$this->assertNoErrors();
$this->assertIdentical($config->get('Core', 'Encoding'), 'iso-8859-1');
// set null to directive that allows null
$config->set('Extension', 'CanBeNull', null);
$this->assertNoErrors();
$this->assertIdentical($config->get('Extension', 'CanBeNull'), null);
$config->set('Extension', 'CanBeNull', 'foobar');
$this->assertNoErrors();
$this->assertIdentical($config->get('Extension', 'CanBeNull'), 'foobar');
// set null to directive that doesn't allow null
$this->expectError('Value is of invalid type');
$config->set('Extension', 'Pert', null);
$this->assertError('Value is of invalid type');
$this->assertNoErrors();
// grab a namespace
$config->set('Attr', 'Key', 0xBEEF);
@ -116,9 +107,8 @@ class HTMLPurifier_ConfigTest extends UnitTestCase
);
// grab a non-existant namespace
$this->expectError('Cannot retrieve undefined namespace');
$config->getBatch('FurnishedGoods');
$this->assertError('Cannot retrieve undefined namespace');
$this->assertNoErrors();
}

View File

@ -29,12 +29,13 @@ class HTMLPurifier_ContextTest extends UnitTestCase
$this->context->destroy('IDAccumulator');
$this->assertFalse($this->context->exists('IDAccumulator'));
$this->expectError('Attempted to retrieve non-existent variable');
$accumulator_3 =& $this->context->get('IDAccumulator');
$this->assertError('Attempted to retrieve non-existent variable');
$this->assertNull($accumulator_3);
$this->expectError('Attempted to destroy non-existent variable');
$this->context->destroy('IDAccumulator');
$this->assertError('Attempted to destroy non-existent variable');
}
@ -42,15 +43,13 @@ class HTMLPurifier_ContextTest extends UnitTestCase
$var = true;
$this->context->register('OnceOnly', $var);
$this->assertNoErrors();
$this->expectError('Name collision, cannot re-register');
$this->context->register('OnceOnly', $var);
$this->assertError('Name collision, cannot re-register');
// destroy it, now registration is okay
$this->context->destroy('OnceOnly');
$this->context->register('OnceOnly', $var);
$this->assertNoErrors();
}

View File

@ -91,11 +91,10 @@ class HTMLPurifier_Strategy_FixNestingTest extends HTMLPurifier_StrategyHarness
'<div>Reject</div>', 'Reject', array('HTML.Parent' => 'span')
);
$this->expectError('Cannot use unrecognized element as parent.');
$this->assertResult(
'<div>Accept</div>', true, array('HTML.Parent' => 'script')
);
$this->assertError('Cannot use unrecognized element as parent.');
$this->assertNoErrors();
}