IDAccumulatorTest.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. class HTMLPurifier_IDAccumulatorTest extends HTMLPurifier_Harness
  3. {
  4. function test() {
  5. // initialize the accumulator
  6. $accumulator = new HTMLPurifier_IDAccumulator();
  7. $this->assertTrue( $accumulator->add('id1'));
  8. $this->assertTrue( $accumulator->add('id2'));
  9. $this->assertFalse($accumulator->add('id1')); // repeated id
  10. // you can also access the properties (they're public)
  11. $this->assertTrue( isset($accumulator->ids['id2']) );
  12. }
  13. function testLoad() {
  14. $accumulator = new HTMLPurifier_IDAccumulator();
  15. $accumulator->load(array('id1', 'id2', 'id3'));
  16. $this->assertFalse($accumulator->add('id1')); // repeated id
  17. $this->assertTrue($accumulator->add('id4'));
  18. }
  19. function testBuild() {
  20. $this->config->set('Attr.IDBlacklist', array('foo'));
  21. $accumulator = HTMLPurifier_IDAccumulator::build($this->config, $this->context);
  22. $this->assertTrue( isset($accumulator->ids['foo']) );
  23. }
  24. }
  25. // vim: et sw=4 sts=4