mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-08-05 21:57:26 +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,29 +1,30 @@
|
||||
<?php
|
||||
|
||||
require_once 'HTMLPurifier/AttrDefHarness.php';
|
||||
require_once 'HTMLPurifier/AttrDef/Class.php';
|
||||
require_once 'HTMLPurifier/Config.php';
|
||||
|
||||
class HTMLPurifier_AttrDef_ClassTest extends UnitTestCase
|
||||
class HTMLPurifier_AttrDef_ClassTest extends HTMLPurifier_AttrDefHarness
|
||||
{
|
||||
|
||||
function testDefault() {
|
||||
|
||||
$def = new HTMLPurifier_AttrDef_Class();
|
||||
$this->def = new HTMLPurifier_AttrDef_Class();
|
||||
|
||||
$this->assertTrue($def->validate('valid'));
|
||||
$this->assertTrue($def->validate('a0-_'));
|
||||
$this->assertTrue($def->validate('-valid'));
|
||||
$this->assertTrue($def->validate('_valid'));
|
||||
$this->assertTrue($def->validate('double valid'));
|
||||
$this->assertDef('valid');
|
||||
$this->assertDef('a0-_');
|
||||
$this->assertDef('-valid');
|
||||
$this->assertDef('_valid');
|
||||
$this->assertDef('double valid');
|
||||
|
||||
$this->assertFalse($def->validate('0invalid'));
|
||||
$this->assertFalse($def->validate('-0'));
|
||||
$this->assertDef('0invalid', false);
|
||||
$this->assertDef('-0', false);
|
||||
|
||||
// test conditional replacement
|
||||
$this->assertEqual('validassoc', $def->validate('validassoc 0invalid'));
|
||||
$this->assertDef('validassoc 0invalid', 'validassoc');
|
||||
|
||||
// test whitespace leniency
|
||||
$this->assertTrue('double valid', $def->validate(" double\nvalid\r"));
|
||||
$this->assertDef(" double\nvalid\r", 'double valid');
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user