2006-07-30 16:35:05 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once 'HTMLPurifier/AttrDef/ID.php';
|
|
|
|
require_once 'HTMLPurifier/IDAccumulator.php';
|
2006-08-04 01:52:54 +00:00
|
|
|
require_once 'HTMLPurifier/Config.php';
|
2006-07-30 16:35:05 +00:00
|
|
|
|
|
|
|
class HTMLPurifier_AttrDef_IDTest extends UnitTestCase
|
|
|
|
{
|
|
|
|
|
|
|
|
function test() {
|
|
|
|
|
|
|
|
$acc = new HTMLPurifier_IDAccumulator();
|
|
|
|
$def = new HTMLPurifier_AttrDef_ID();
|
|
|
|
|
2006-08-04 01:52:54 +00:00
|
|
|
generate_mock_once('HTMLPurifier_Config');
|
|
|
|
|
|
|
|
$config = new HTMLPurifier_ConfigMock();
|
|
|
|
|
2006-07-30 16:35:05 +00:00
|
|
|
// valid ID names
|
2006-08-04 01:52:54 +00:00
|
|
|
$this->assertTrue($def->validate('alpha', $config, $acc));
|
|
|
|
$this->assertTrue($def->validate('al_ha', $config, $acc));
|
|
|
|
$this->assertTrue($def->validate('a0-:.', $config, $acc));
|
|
|
|
$this->assertTrue($def->validate('a' , $config, $acc));
|
2006-07-30 16:35:05 +00:00
|
|
|
|
|
|
|
// invalid ID names
|
2006-08-04 01:52:54 +00:00
|
|
|
$this->assertFalse($def->validate('<asa', $config, $acc));
|
|
|
|
$this->assertFalse($def->validate('0123', $config, $acc));
|
|
|
|
$this->assertFalse($def->validate('.asa', $config, $acc));
|
2006-07-30 16:35:05 +00:00
|
|
|
|
|
|
|
// test duplicate detection
|
2006-08-04 01:52:54 +00:00
|
|
|
$this->assertFalse($def->validate('a' , $config, $acc));
|
2006-07-30 16:35:05 +00:00
|
|
|
|
2006-08-04 00:11:54 +00:00
|
|
|
// valid once whitespace stripped, but needs to be amended
|
2006-08-04 01:52:54 +00:00
|
|
|
$this->assertEqual('whee', $def->validate(' whee ', $config, $acc));
|
2006-08-04 00:11:54 +00:00
|
|
|
|
2006-07-30 16:35:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|