CleanPre.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /**
  3. * The clean_pre() removes pararaph and line break
  4. * tags within `<pre>` elements as part of wpautop().
  5. *
  6. * @group formatting
  7. * @expectedDeprecated clean_pre
  8. */
  9. class Tests_Formatting_CleanPre extends WP_UnitTestCase {
  10. function test_removes_self_closing_br_with_space() {
  11. $source = 'a b c\n<br />sldfj<br />';
  12. $res = 'a b c\nsldfj';
  13. $this->assertEquals($res, clean_pre($source));
  14. }
  15. function test_removes_self_closing_br_without_space() {
  16. $source = 'a b c\n<br/>sldfj<br/>';
  17. $res = 'a b c\nsldfj';
  18. $this->assertEquals($res, clean_pre($source));
  19. }
  20. // I don't think this can ever happen in production;
  21. // <br> is changed to <br /> elsewhere. Left in because
  22. // that replacement shouldn't happen (what if you want
  23. // HTML 4 output?).
  24. function test_removes_html_br() {
  25. $source = 'a b c\n<br>sldfj<br>';
  26. $res = 'a b c\nsldfj';
  27. $this->assertEquals($res, clean_pre($source));
  28. }
  29. function test_removes_p() {
  30. $source = "<p>isn't this exciting!</p><p>oh indeed!</p>";
  31. $res = "\nisn't this exciting!\noh indeed!";
  32. $this->assertEquals($res, clean_pre($source));
  33. }
  34. }