No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

ValidateAttributes_IDTest.php 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. class HTMLPurifier_Strategy_ValidateAttributes_IDTest extends HTMLPurifier_StrategyHarness
  3. {
  4. public function setUp()
  5. {
  6. parent::setUp();
  7. $this->obj = new HTMLPurifier_Strategy_ValidateAttributes();
  8. $this->config->set('Attr.EnableID', true);
  9. }
  10. public function testPreserveIDWhenEnabled()
  11. {
  12. $this->assertResult('<div id="valid">Preserve the ID.</div>');
  13. }
  14. public function testRemoveInvalidID()
  15. {
  16. $this->assertResult(
  17. '<div id="0invalid">Kill the ID.</div>',
  18. '<div>Kill the ID.</div>'
  19. );
  20. }
  21. public function testRemoveDuplicateID()
  22. {
  23. $this->assertResult(
  24. '<div id="valid">Valid</div><div id="valid">Invalid</div>',
  25. '<div id="valid">Valid</div><div>Invalid</div>'
  26. );
  27. }
  28. public function testAttributeKeyCaseInsensitivity()
  29. {
  30. $this->assertResult(
  31. '<div ID="valid">Convert ID to lowercase.</div>',
  32. '<div id="valid">Convert ID to lowercase.</div>'
  33. );
  34. }
  35. public function testTrimWhitespace()
  36. {
  37. $this->assertResult(
  38. '<div id=" valid ">Trim whitespace.</div>',
  39. '<div id="valid">Trim whitespace.</div>'
  40. );
  41. }
  42. public function testIDBlacklist()
  43. {
  44. $this->config->set('Attr.IDBlacklist', array('invalid'));
  45. $this->assertResult(
  46. '<div id="invalid">Invalid</div>',
  47. '<div>Invalid</div>'
  48. );
  49. }
  50. public function testNameConvertedToID()
  51. {
  52. $this->config->set('HTML.TidyLevel', 'heavy');
  53. $this->assertResult(
  54. '<a name="foobar" />',
  55. '<a id="foobar" />'
  56. );
  57. }
  58. }
  59. // vim: et sw=4 sts=4