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.4KB

  1. <?php
  2. class HTMLPurifier_ChildDef_StrictBlockquoteTest
  3. extends HTMLPurifier_ChildDefHarness
  4. {
  5. public function setUp()
  6. {
  7. parent::setUp();
  8. $this->obj = new HTMLPurifier_ChildDef_StrictBlockquote('div | p');
  9. }
  10. public function testEmptyInput()
  11. {
  12. $this->assertResult('');
  13. }
  14. public function testPreserveValidP()
  15. {
  16. $this->assertResult('<p>Valid</p>');
  17. }
  18. public function testPreserveValidDiv()
  19. {
  20. $this->assertResult('<div>Still valid</div>');
  21. }
  22. public function testWrapTextWithP()
  23. {
  24. $this->assertResult('Needs wrap', '<p>Needs wrap</p>');
  25. }
  26. public function testNoWrapForWhitespaceOrValidElements()
  27. {
  28. $this->assertResult('<p>Do not wrap</p> <p>Whitespace</p>');
  29. }
  30. public function testWrapTextNextToValidElements()
  31. {
  32. $this->assertResult(
  33. 'Wrap'. '<p>Do not wrap</p>',
  34. '<p>Wrap</p><p>Do not wrap</p>'
  35. );
  36. }
  37. public function testWrapInlineElements()
  38. {
  39. $this->assertResult(
  40. '<p>Do not</p>'.'<b>Wrap</b>',
  41. '<p>Do not</p><p><b>Wrap</b></p>'
  42. );
  43. }
  44. public function testWrapAndRemoveInvalidTags()
  45. {
  46. $this->assertResult(
  47. '<li>Not allowed</li>Paragraph.<p>Hmm.</p>',
  48. '<p>Not allowedParagraph.</p><p>Hmm.</p>'
  49. );
  50. }
  51. public function testWrapComplicatedSring()
  52. {
  53. $this->assertResult(
  54. $var = 'He said<br />perhaps<br />we should <b>nuke</b> them.',
  55. "<p>$var</p>"
  56. );
  57. }
  58. public function testWrapAndRemoveInvalidTagsComplex()
  59. {
  60. $this->assertResult(
  61. '<foo>Bar</foo><bas /><b>People</b>Conniving.'. '<p>Fools!</p>',
  62. '<p>Bar'. '<b>People</b>Conniving.</p><p>Fools!</p>'
  63. );
  64. }
  65. public function testAlternateWrapper()
  66. {
  67. $this->config->set('HTML.BlockWrapper', 'div');
  68. $this->assertResult('Needs wrap', '<div>Needs wrap</div>');
  69. }
  70. public function testError()
  71. {
  72. $this->expectError('Cannot use non-block element as block wrapper');
  73. $this->obj = new HTMLPurifier_ChildDef_StrictBlockquote('div | p');
  74. $this->config->set('HTML.BlockWrapper', 'dav');
  75. $this->config->set('Cache.DefinitionImpl', null);
  76. $this->assertResult('Needs wrap', '<p>Needs wrap</p>');
  77. }
  78. }
  79. // vim: et sw=4 sts=4