2006-07-30 15:52:25 +00:00
|
|
|
<?php
|
|
|
|
|
2007-08-01 14:06:59 +00:00
|
|
|
class HTMLPurifier_IDAccumulatorTest extends HTMLPurifier_Harness
|
2006-07-30 15:52:25 +00:00
|
|
|
{
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-07-30 15:52:25 +00:00
|
|
|
function test() {
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-07-30 15:52:25 +00:00
|
|
|
// initialize the accumulator
|
2006-07-30 16:01:24 +00:00
|
|
|
$accumulator = new HTMLPurifier_IDAccumulator();
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-07-30 15:52:25 +00:00
|
|
|
$this->assertTrue( $accumulator->add('id1'));
|
|
|
|
$this->assertTrue( $accumulator->add('id2'));
|
|
|
|
$this->assertFalse($accumulator->add('id1')); // repeated id
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-07-30 16:35:05 +00:00
|
|
|
// you can also access the properties (they're public)
|
|
|
|
$this->assertTrue( isset($accumulator->ids['id2']) );
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-07-30 16:35:05 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-07-30 16:35:05 +00:00
|
|
|
function testLoad() {
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-07-30 16:35:05 +00:00
|
|
|
$accumulator = new HTMLPurifier_IDAccumulator();
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-07-30 16:35:05 +00:00
|
|
|
$accumulator->load(array('id1', 'id2', 'id3'));
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-07-30 16:35:05 +00:00
|
|
|
$this->assertFalse($accumulator->add('id1')); // repeated id
|
|
|
|
$this->assertTrue($accumulator->add('id4'));
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-07-30 15:52:25 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-09-26 23:36:37 +00:00
|
|
|
function testBuild() {
|
2009-02-20 00:17:49 +00:00
|
|
|
$this->config->set('Attr.IDBlacklist', array('foo'));
|
2007-09-26 23:36:37 +00:00
|
|
|
$accumulator = HTMLPurifier_IDAccumulator::build($this->config, $this->context);
|
|
|
|
$this->assertTrue( isset($accumulator->ids['foo']) );
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-07-30 15:52:25 +00:00
|
|
|
}
|
|
|
|
|
2008-12-06 09:24:59 +00:00
|
|
|
// vim: et sw=4 sts=4
|