StrictBlockquoteTest.php 2.2 KB

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