You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

IDAccumulatorTest.php 1.1KB

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