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.

97 lines
2.3KB

  1. <?php
  2. class HTMLPurifier_Injector_RemoveEmptyTest extends HTMLPurifier_InjectorHarness
  3. {
  4. public function setup()
  5. {
  6. parent::setup();
  7. $this->config->set('AutoFormat.RemoveEmpty', true);
  8. }
  9. public function testPreserve()
  10. {
  11. $this->assertResult('<b>asdf</b>');
  12. }
  13. public function testRemove()
  14. {
  15. $this->assertResult('<b></b>', '');
  16. }
  17. public function testRemoveWithSpace()
  18. {
  19. $this->assertResult('<b> </b>', '');
  20. }
  21. public function testRemoveWithAttr()
  22. {
  23. $this->assertResult('<b class="asdf"></b>', '');
  24. }
  25. public function testRemoveIdAndName()
  26. {
  27. $this->assertResult('<a id="asdf" name="asdf"></a>', '');
  28. }
  29. public function testPreserveColgroup()
  30. {
  31. $this->assertResult('<colgroup></colgroup>');
  32. }
  33. public function testPreserveId()
  34. {
  35. $this->config->set('Attr.EnableID', true);
  36. $this->assertResult('<a id="asdf"></a>');
  37. }
  38. public function testPreserveName()
  39. {
  40. $this->config->set('Attr.EnableID', true);
  41. $this->assertResult('<a name="asdf"></a>');
  42. }
  43. public function testRemoveNested()
  44. {
  45. $this->assertResult('<b><i></i></b>', '');
  46. }
  47. public function testRemoveNested2()
  48. {
  49. $this->assertResult('<b><i><u></u></i></b>', '');
  50. }
  51. public function testRemoveNested3()
  52. {
  53. $this->assertResult('<b> <i> <u> </u> </i> </b>', '');
  54. }
  55. public function testRemoveNbsp()
  56. {
  57. $this->config->set('AutoFormat.RemoveEmpty.RemoveNbsp', true);
  58. $this->assertResult('<b>&nbsp;</b>', '');
  59. }
  60. public function testRemoveNbspMix()
  61. {
  62. $this->config->set('AutoFormat.RemoveEmpty.RemoveNbsp', true);
  63. $this->assertResult('<b>&nbsp; &nbsp;</b>', '');
  64. }
  65. public function testDontRemoveNbsp()
  66. {
  67. $this->config->set('AutoFormat.RemoveEmpty.RemoveNbsp', true);
  68. $this->assertResult('<td>&nbsp;</b>', "<td>\xC2\xA0</td>");
  69. }
  70. public function testRemoveNbspExceptionsSpecial()
  71. {
  72. $this->config->set('AutoFormat.RemoveEmpty.RemoveNbsp', true);
  73. $this->config->set('AutoFormat.RemoveEmpty.RemoveNbsp.Exceptions', 'b');
  74. $this->assertResult('<b>&nbsp;</b>', "<b>\xC2\xA0</b>");
  75. }
  76. }
  77. // vim: et sw=4 sts=4