Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

113 linhas
2.8KB

  1. <?php
  2. class HTMLPurifier_Injector_RemoveSpansWithoutAttributesTest extends HTMLPurifier_InjectorHarness
  3. {
  4. public function setup()
  5. {
  6. parent::setup();
  7. $this->config->set('HTML.Allowed', 'span[class],div,p,strong,em');
  8. $this->config->set('AutoFormat.RemoveSpansWithoutAttributes', true);
  9. }
  10. public function testSingleSpan()
  11. {
  12. $this->assertResult(
  13. '<span>foo</span>',
  14. 'foo'
  15. );
  16. }
  17. public function testSingleSpanWithAttributes()
  18. {
  19. $this->assertResult(
  20. '<span class="bar">foo</span>',
  21. '<span class="bar">foo</span>'
  22. );
  23. }
  24. public function testSingleNestedSpan()
  25. {
  26. $this->assertResult(
  27. '<p><span>foo</span></p>',
  28. '<p>foo</p>'
  29. );
  30. }
  31. public function testSingleNestedSpanWithAttributes()
  32. {
  33. $this->assertResult(
  34. '<p><span class="bar">foo</span></p>',
  35. '<p><span class="bar">foo</span></p>'
  36. );
  37. }
  38. public function testSpanWithChildren()
  39. {
  40. $this->assertResult(
  41. '<span>foo <strong>bar</strong> <em>baz</em></span>',
  42. 'foo <strong>bar</strong> <em>baz</em>'
  43. );
  44. }
  45. public function testSpanWithSiblings()
  46. {
  47. $this->assertResult(
  48. '<p>before <span>inside</span> <strong>after</strong></p>',
  49. '<p>before inside <strong>after</strong></p>'
  50. );
  51. }
  52. public function testNestedSpanWithSiblingsAndChildren()
  53. {
  54. $this->assertResult(
  55. '<p>a <span>b <em>c</em> d</span> e</p>',
  56. '<p>a b <em>c</em> d e</p>'
  57. );
  58. }
  59. public function testNestedSpansWithoutAttributes()
  60. {
  61. $this->assertResult(
  62. '<span>one<span>two<span>three</span></span></span>',
  63. 'onetwothree'
  64. );
  65. }
  66. public function testDeeplyNestedSpan()
  67. {
  68. $this->assertResult(
  69. '<div><div><div><span class="a">a <span>b</span> c</span></div></div></div>',
  70. '<div><div><div><span class="a">a b c</span></div></div></div>'
  71. );
  72. }
  73. public function testSpanWithInvalidAttributes()
  74. {
  75. $this->assertResult(
  76. '<p><span snorkel buzzer="emu">foo</span></p>',
  77. '<p>foo</p>'
  78. );
  79. }
  80. public function testNestedAlternateSpans()
  81. {
  82. $this->assertResult(
  83. '<span>a <span class="x">b <span>c <span class="y">d <span>e <span class="z">f
  84. </span></span></span></span></span></span>',
  85. 'a <span class="x">b c <span class="y">d e <span class="z">f
  86. </span></span></span>'
  87. );
  88. }
  89. public function testSpanWithSomeInvalidAttributes()
  90. {
  91. $this->assertResult(
  92. '<p><span buzzer="emu" class="bar">foo</span></p>',
  93. '<p><span class="bar">foo</span></p>'
  94. );
  95. }
  96. }
  97. // vim: et sw=4 sts=4