NameSyncTest.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. class HTMLPurifier_AttrTransform_NameSyncTest extends HTMLPurifier_AttrTransformHarness
  3. {
  4. /**
  5. * @type HTMLPurifier_IDAccumulator
  6. */
  7. public $accumulator;
  8. public function setUp()
  9. {
  10. parent::setUp();
  11. $this->obj = new HTMLPurifier_AttrTransform_NameSync();
  12. $this->accumulator = new HTMLPurifier_IDAccumulator();
  13. $this->context->register('IDAccumulator', $this->accumulator);
  14. $this->config->set('Attr.EnableID', true);
  15. }
  16. public function testEmpty()
  17. {
  18. $this->assertResult( array() );
  19. }
  20. public function testAllowSame()
  21. {
  22. $this->assertResult(
  23. array('name' => 'free', 'id' => 'free')
  24. );
  25. }
  26. public function testAllowDifferent()
  27. {
  28. $this->assertResult(
  29. array('name' => 'tryit', 'id' => 'thisgood')
  30. );
  31. }
  32. public function testCheckName()
  33. {
  34. $this->accumulator->add('notok');
  35. $this->assertResult(
  36. array('name' => 'notok', 'id' => 'ok'),
  37. array('id' => 'ok')
  38. );
  39. }
  40. }
  41. // vim: et sw=4 sts=4