ConvertChars.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /**
  3. * @group formatting
  4. */
  5. class Tests_Formatting_ConvertChars extends WP_UnitTestCase {
  6. function test_replaces_windows1252_entities_with_unicode_ones() {
  7. $input = "&#130;&#131;&#132;&#133;&#134;&#135;&#136;&#137;&#138;&#139;&#140;&#145;&#146;&#147;&#148;&#149;&#150;&#151;&#152;&#153;&#154;&#155;&#156;&#159;";
  8. $output = "&#8218;&#402;&#8222;&#8230;&#8224;&#8225;&#710;&#8240;&#352;&#8249;&#338;&#8216;&#8217;&#8220;&#8221;&#8226;&#8211;&#8212;&#732;&#8482;&#353;&#8250;&#339;&#376;";
  9. $this->assertEquals($output, convert_chars($input));
  10. }
  11. /**
  12. * @ticket 20503
  13. */
  14. function test_replaces_latin_letter_z_with_caron() {
  15. $input = "&#142;&#158;";
  16. $output = "&#381;&#382;";
  17. $this->assertEquals( $output, convert_chars( $input ) );
  18. }
  19. function test_converts_html_br_and_hr_to_the_xhtml_self_closing_variety() {
  20. $inputs = array(
  21. "abc <br> lol <br />" => "abc <br /> lol <br />",
  22. "<br> ho ho <hr>" => "<br /> ho ho <hr />",
  23. "<hr><br>" => "<hr /><br />"
  24. );
  25. foreach ($inputs as $input => $expected) {
  26. $this->assertEquals($expected, convert_chars($input));
  27. }
  28. }
  29. function test_escapes_lone_ampersands() {
  30. $this->assertEquals("at&#038;t", convert_chars("at&t"));
  31. }
  32. function test_removes_category_and_title_metadata_tags() {
  33. $this->assertEquals("", convert_chars("<title><div class='lol'>abc</div></title><category>a</category>"));
  34. }
  35. }