2006-07-30 16:35:05 +00:00
|
|
|
<?php
|
|
|
|
|
2006-08-05 00:30:31 +00:00
|
|
|
require_once 'HTMLPurifier/AttrDefHarness.php';
|
2006-07-30 16:35:05 +00:00
|
|
|
require_once 'HTMLPurifier/AttrDef/ID.php';
|
|
|
|
require_once 'HTMLPurifier/IDAccumulator.php';
|
|
|
|
|
2006-08-05 00:30:31 +00:00
|
|
|
class HTMLPurifier_AttrDef_IDTest extends HTMLPurifier_AttrDefHarness
|
2006-07-30 16:35:05 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
function test() {
|
|
|
|
|
2006-08-12 16:04:40 +00:00
|
|
|
$this->context = new HTMLPurifier_AttrContext();
|
|
|
|
$this->context->id_accumulator = new HTMLPurifier_IDAccumulator();
|
2006-08-05 00:30:31 +00:00
|
|
|
$this->def = new HTMLPurifier_AttrDef_ID();
|
2006-08-04 01:52:54 +00:00
|
|
|
|
2006-07-30 16:35:05 +00:00
|
|
|
// valid ID names
|
2006-08-05 00:30:31 +00:00
|
|
|
$this->assertDef('alpha');
|
|
|
|
$this->assertDef('al_ha');
|
|
|
|
$this->assertDef('a0-:.');
|
|
|
|
$this->assertDef('a');
|
2006-07-30 16:35:05 +00:00
|
|
|
|
|
|
|
// invalid ID names
|
2006-08-05 00:30:31 +00:00
|
|
|
$this->assertDef('<asa', false);
|
|
|
|
$this->assertDef('0123', false);
|
|
|
|
$this->assertDef('.asa', false);
|
2006-07-30 16:35:05 +00:00
|
|
|
|
|
|
|
// test duplicate detection
|
2006-08-05 00:30:31 +00:00
|
|
|
$this->assertDef('a', false);
|
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-05 00:30:31 +00:00
|
|
|
$this->assertDef(' whee ', 'whee');
|
2006-08-04 00:11:54 +00:00
|
|
|
|
2006-07-30 16:35:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|