mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-07-31 19:30:21 +02:00
Refactor unit tests so that abstract test cases are now called Harnesses and AttrDef tests use their harness's assertDef() function, which enforces type much better. Also fixed a few bugs.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@161 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
@@ -1,33 +1,34 @@
|
||||
<?php
|
||||
|
||||
require_once 'HTMLPurifier/AttrDefHarness.php';
|
||||
require_once 'HTMLPurifier/AttrDef/Enum.php';
|
||||
|
||||
class HTMLPurifier_AttrDef_EnumTest extends UnitTestCase
|
||||
class HTMLPurifier_AttrDef_EnumTest extends HTMLPurifier_AttrDefHarness
|
||||
{
|
||||
|
||||
function testCaseInsensitive() {
|
||||
|
||||
$def = new HTMLPurifier_AttrDef_Enum(array('one', 'two'));
|
||||
$this->def = new HTMLPurifier_AttrDef_Enum(array('one', 'two'));
|
||||
|
||||
$this->assertTrue($def->validate('one'));
|
||||
$this->assertTrue($def->validate('ONE'));
|
||||
$this->assertDef('one');
|
||||
$this->assertDef('ONE', 'one');
|
||||
|
||||
}
|
||||
|
||||
function testCaseSensitive() {
|
||||
|
||||
$def = new HTMLPurifier_AttrDef_Enum(array('one', 'two'), true);
|
||||
$this->def = new HTMLPurifier_AttrDef_Enum(array('one', 'two'), true);
|
||||
|
||||
$this->assertTrue($def->validate('one'));
|
||||
$this->assertFalse($def->validate('ONE'));
|
||||
$this->assertDef('one');
|
||||
$this->assertDef('ONE', false);
|
||||
|
||||
}
|
||||
|
||||
function testFixing() {
|
||||
|
||||
$def = new HTMLPurifier_AttrDef_Enum(array('one'));
|
||||
$this->def = new HTMLPurifier_AttrDef_Enum(array('one'));
|
||||
|
||||
$this->assertEqual('one', $def->validate(' one '));
|
||||
$this->assertDef(' one ', 'one');
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user