Changeset 52010 for trunk/tests/phpunit/tests/formatting/wpTexturize.php
- Timestamp:
- 11/04/2021 03:22:47 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/formatting/wpTexturize.php
r51623 r52010 5 5 */ 6 6 class Tests_Formatting_wpTexturize extends WP_UnitTestCase { 7 function test_dashes() {7 public function test_dashes() { 8 8 $this->assertSame( 'Hey — boo?', wptexturize( 'Hey -- boo?' ) ); 9 9 $this->assertSame( '<a href="http://xx--xx">Hey — boo?</a>', wptexturize( '<a href="http://xx--xx">Hey -- boo?</a>' ) ); 10 10 } 11 11 12 function test_disable() {12 public function test_disable() { 13 13 $this->assertSame( '<pre>---&</pre>', wptexturize( '<pre>---&</pre>' ) ); 14 14 $this->assertSame( '<pre><code></code>--&</pre>', wptexturize( '<pre><code></code>--&</pre>' ) ); … … 36 36 * @ticket 1418 37 37 */ 38 function test_bracketed_quotes_1418() {38 public function test_bracketed_quotes_1418() { 39 39 $this->assertSame( '(“test”)', wptexturize( '("test")' ) ); 40 40 $this->assertSame( '(‘test’)', wptexturize( "('test')" ) ); … … 45 45 * @ticket 3810 46 46 */ 47 function test_bracketed_quotes_3810() {47 public function test_bracketed_quotes_3810() { 48 48 $this->assertSame( 'A dog (“Hubertus”) was sent out.', wptexturize( 'A dog ("Hubertus") was sent out.' ) ); 49 49 } … … 52 52 * @ticket 4539 53 53 */ 54 function test_basic_quotes() {54 public function test_basic_quotes() { 55 55 $this->assertSame( 'test’s', wptexturize( 'test\'s' ) ); 56 56 … … 75 75 * @ticket 15241 76 76 */ 77 function test_full_sentences_with_unmatched_single_quotes() {77 public function test_full_sentences_with_unmatched_single_quotes() { 78 78 $this->assertSame( 79 79 'That means every moment you’re working on something without it being in the public it’s actually dying.', … … 85 85 * @ticket 4539 86 86 */ 87 function test_quotes() {87 public function test_quotes() { 88 88 $this->assertSame( '“Quoted String”', wptexturize( '"Quoted String"' ) ); 89 89 // $this->assertSame( 'Here is “<a href="http://example.com">a test with a link</a>”', wptexturize( 'Here is "<a href="http://example.com">a test with a link</a>"' ) ); … … 104 104 * @ticket 4539 105 105 */ 106 function test_quotes_before_s() {106 public function test_quotes_before_s() { 107 107 $this->assertSame( 'test’s', wptexturize( "test's" ) ); 108 108 $this->assertSame( '‘test’s', wptexturize( "'test's" ) ); … … 115 115 * @ticket 4539 116 116 */ 117 function test_quotes_before_numbers() {117 public function test_quotes_before_numbers() { 118 118 $this->assertSame( 'Class of ’99', wptexturize( "Class of '99" ) ); 119 119 $this->assertSame( 'Class of ’99’s', wptexturize( "Class of '99's" ) ); … … 142 142 } 143 143 144 function test_quotes_after_numbers() {144 public function test_quotes_after_numbers() { 145 145 $this->assertSame( 'Class of ’99', wptexturize( "Class of '99" ) ); 146 146 } … … 150 150 * @ticket 15241 151 151 */ 152 function test_other_html() {152 public function test_other_html() { 153 153 $this->assertSame( '‘<strong>', wptexturize( "'<strong>" ) ); 154 154 // $this->assertSame( '‘<strong>Quoted Text</strong>’,', wptexturize( "'<strong>Quoted Text</strong>'," ) ); … … 156 156 } 157 157 158 function test_x() {158 public function test_x() { 159 159 $this->assertSame( '14×24', wptexturize( '14x24' ) ); 160 160 } 161 161 162 function test_minutes_seconds() {162 public function test_minutes_seconds() { 163 163 $this->assertSame( '9′', wptexturize( '9\'' ) ); 164 164 $this->assertSame( '9″', wptexturize( '9"' ) ); … … 174 174 * @ticket 8775 175 175 */ 176 function test_wptexturize_quotes_around_numbers() {176 public function test_wptexturize_quotes_around_numbers() { 177 177 $this->assertSame( '“12345”', wptexturize( '"12345"' ) ); 178 178 $this->assertSame( '‘12345’', wptexturize( '\'12345\'' ) ); … … 184 184 * @ticket 8912 185 185 */ 186 function test_wptexturize_html_comments() {186 public function test_wptexturize_html_comments() { 187 187 $this->assertSame( '<!--[if !IE]>--><!--<![endif]-->', wptexturize( '<!--[if !IE]>--><!--<![endif]-->' ) ); 188 188 $this->assertSame( '<!--[if !IE]>"a 9\' plus a \'9\', maybe a 9\' \'9\' "<![endif]-->', wptexturize( '<!--[if !IE]>"a 9\' plus a \'9\', maybe a 9\' \'9\' "<![endif]-->' ) ); … … 194 194 * @ticket 15241 195 195 */ 196 function test_entity_quote_cuddling() {196 public function test_entity_quote_cuddling() { 197 197 $this->assertSame( ' “Testing”', wptexturize( ' "Testing"' ) ); 198 198 // $this->assertSame( '&“Testing”', wptexturize( '&"Testing"' ) ); … … 202 202 * @ticket 22823 203 203 */ 204 function test_apostrophes_before_primes() {204 public function test_apostrophes_before_primes() { 205 205 $this->assertSame( 'WordPress 3.5’s release date', wptexturize( "WordPress 3.5's release date" ) ); 206 206 } … … 209 209 * @ticket 23185 210 210 */ 211 function test_spaces_around_hyphens() {211 public function test_spaces_around_hyphens() { 212 212 $nbsp = "\xC2\xA0"; 213 213 … … 232 232 * @ticket 31030 233 233 */ 234 function test_hyphens_at_start_and_end() {234 public function test_hyphens_at_start_and_end() { 235 235 $this->assertSame( '– ', wptexturize( '- ' ) ); 236 236 $this->assertSame( '– –', wptexturize( '- -' ) ); … … 249 249 * @ticket 22692 250 250 */ 251 function test_spaces_around_quotes_never() {251 public function test_spaces_around_quotes_never() { 252 252 $nbsp = "\xC2\xA0"; 253 253 … … 266 266 * @dataProvider data_spaces_around_quotes 267 267 */ 268 function test_spaces_around_quotes( $input, $output ) {268 public function test_spaces_around_quotes( $input, $output ) { 269 269 return $this->assertSame( $output, wptexturize( $input ) ); 270 270 } 271 271 272 function data_spaces_around_quotes() {272 public function data_spaces_around_quotes() { 273 273 $nbsp = "\xC2\xA0"; 274 274 $pi = "\xCE\xA0"; … … 322 322 * @dataProvider data_apos_before_digits 323 323 */ 324 function test_apos_before_digits( $input, $output ) {324 public function test_apos_before_digits( $input, $output ) { 325 325 return $this->assertSame( $output, wptexturize( $input ) ); 326 326 } 327 327 328 function data_apos_before_digits() {328 public function data_apos_before_digits() { 329 329 return array( 330 330 array( … … 363 363 * @dataProvider data_opening_single_quote 364 364 */ 365 function test_opening_single_quote( $input, $output ) {365 public function test_opening_single_quote( $input, $output ) { 366 366 return $this->assertSame( $output, wptexturize( $input ) ); 367 367 } 368 368 369 function data_opening_single_quote() {369 public function data_opening_single_quote() { 370 370 return array( 371 371 array( … … 492 492 * @dataProvider data_double_prime 493 493 */ 494 function test_double_prime( $input, $output ) {494 public function test_double_prime( $input, $output ) { 495 495 return $this->assertSame( $output, wptexturize( $input ) ); 496 496 } 497 497 498 function data_double_prime() {498 public function data_double_prime() { 499 499 return array( 500 500 array( … … 525 525 * @dataProvider data_single_prime 526 526 */ 527 function test_single_prime( $input, $output ) {527 public function test_single_prime( $input, $output ) { 528 528 return $this->assertSame( $output, wptexturize( $input ) ); 529 529 } 530 530 531 function data_single_prime() {531 public function data_single_prime() { 532 532 return array( 533 533 array( … … 558 558 * @dataProvider data_contractions 559 559 */ 560 function test_contractions( $input, $output ) {560 public function test_contractions( $input, $output ) { 561 561 return $this->assertSame( $output, wptexturize( $input ) ); 562 562 } 563 563 564 function data_contractions() {564 public function data_contractions() { 565 565 return array( 566 566 array( … … 599 599 * @dataProvider data_opening_quote 600 600 */ 601 function test_opening_quote( $input, $output ) {601 public function test_opening_quote( $input, $output ) { 602 602 return $this->assertSame( $output, wptexturize( $input ) ); 603 603 } 604 604 605 function data_opening_quote() {605 public function data_opening_quote() { 606 606 return array( 607 607 array( … … 676 676 * @dataProvider data_closing_quote 677 677 */ 678 function test_closing_quote( $input, $output ) {678 public function test_closing_quote( $input, $output ) { 679 679 return $this->assertSame( $output, wptexturize( $input ) ); 680 680 } 681 681 682 function data_closing_quote() {682 public function data_closing_quote() { 683 683 return array( 684 684 array( … … 765 765 * @dataProvider data_closing_single_quote 766 766 */ 767 function test_closing_single_quote( $input, $output ) {767 public function test_closing_single_quote( $input, $output ) { 768 768 return $this->assertSame( $output, wptexturize( $input ) ); 769 769 } 770 770 771 function data_closing_single_quote() {771 public function data_closing_single_quote() { 772 772 return array( 773 773 array( … … 855 855 * @dataProvider data_multiplication 856 856 */ 857 function test_multiplication( $input, $output ) {857 public function test_multiplication( $input, $output ) { 858 858 return $this->assertSame( $output, wptexturize( $input ) ); 859 859 } 860 860 861 function data_multiplication() {861 public function data_multiplication() { 862 862 return array( 863 863 array( … … 905 905 * @dataProvider data_ampersand 906 906 */ 907 function test_ampersand( $input, $output ) {907 public function test_ampersand( $input, $output ) { 908 908 return $this->assertSame( $output, wptexturize( $input ) ); 909 909 } 910 910 911 function data_ampersand() {911 public function data_ampersand() { 912 912 return array( 913 913 array( … … 970 970 * @dataProvider data_cockney 971 971 */ 972 function test_cockney( $input, $output ) {972 public function test_cockney( $input, $output ) { 973 973 return $this->assertSame( $output, wptexturize( $input ) ); 974 974 } 975 975 976 function data_cockney() {976 public function data_cockney() { 977 977 return array( 978 978 array( … … 1031 1031 * @dataProvider data_smart_dashes 1032 1032 */ 1033 function test_smart_dashes( $input, $output ) {1033 public function test_smart_dashes( $input, $output ) { 1034 1034 return $this->assertSame( $output, wptexturize( $input ) ); 1035 1035 } 1036 1036 1037 function data_smart_dashes() {1037 public function data_smart_dashes() { 1038 1038 return array( 1039 1039 array( … … 1084 1084 * @dataProvider data_misc_static_replacements 1085 1085 */ 1086 function test_misc_static_replacements( $input, $output ) {1086 public function test_misc_static_replacements( $input, $output ) { 1087 1087 return $this->assertSame( $output, wptexturize( $input ) ); 1088 1088 } 1089 1089 1090 function data_misc_static_replacements() {1090 public function data_misc_static_replacements() { 1091 1091 return array( 1092 1092 array( … … 1139 1139 * @dataProvider data_quoted_numbers 1140 1140 */ 1141 function test_quoted_numbers( $input, $output ) {1141 public function test_quoted_numbers( $input, $output ) { 1142 1142 return $this->assertSame( $output, wptexturize( $input ) ); 1143 1143 } 1144 1144 1145 function data_quoted_numbers() {1145 public function data_quoted_numbers() { 1146 1146 return array( 1147 1147 array( … … 1190 1190 * @dataProvider data_quotes_and_dashes 1191 1191 */ 1192 function test_quotes_and_dashes( $input, $output ) {1192 public function test_quotes_and_dashes( $input, $output ) { 1193 1193 return $this->assertSame( $output, wptexturize( $input ) ); 1194 1194 } 1195 1195 1196 function data_quotes_and_dashes() {1196 public function data_quotes_and_dashes() { 1197 1197 return array( 1198 1198 array( … … 1253 1253 * @dataProvider data_tag_avoidance 1254 1254 */ 1255 function test_tag_avoidance( $input, $output ) {1255 public function test_tag_avoidance( $input, $output ) { 1256 1256 return $this->assertSame( $output, wptexturize( $input ) ); 1257 1257 } 1258 1258 1259 function data_tag_avoidance() {1259 public function data_tag_avoidance() { 1260 1260 return array( 1261 1261 array( … … 1476 1476 * @dataProvider data_year_abbr 1477 1477 */ 1478 function test_year_abbr( $input, $output ) {1478 public function test_year_abbr( $input, $output ) { 1479 1479 return $this->assertSame( $output, wptexturize( $input ) ); 1480 1480 } 1481 1481 1482 function data_year_abbr() {1482 public function data_year_abbr() { 1483 1483 return array( 1484 1484 array( … … 1565 1565 * @dataProvider data_translate 1566 1566 */ 1567 function test_translate( $input, $output ) {1567 public function test_translate( $input, $output ) { 1568 1568 add_filter( 'gettext_with_context', array( $this, 'filter_translate' ), 10, 4 ); 1569 1569 … … 1576 1576 } 1577 1577 1578 function filter_translate( $translations, $text, $context, $domain ) {1578 public function filter_translate( $translations, $text, $context, $domain ) { 1579 1579 switch ( $text ) { 1580 1580 case '–': … … 1605 1605 } 1606 1606 1607 function data_translate() {1607 public function data_translate() { 1608 1608 return array( 1609 1609 array( … … 1792 1792 * @dataProvider data_element_stack 1793 1793 */ 1794 function test_element_stack( $input, $output ) {1794 public function test_element_stack( $input, $output ) { 1795 1795 return $this->assertSame( $output, wptexturize( $input ) ); 1796 1796 } 1797 1797 1798 function data_element_stack() {1798 public function data_element_stack() { 1799 1799 return array( 1800 1800 array( … … 1843 1843 * @dataProvider data_unregistered_shortcodes 1844 1844 */ 1845 function test_unregistered_shortcodes( $input, $output ) {1845 public function test_unregistered_shortcodes( $input, $output ) { 1846 1846 add_filter( 'no_texturize_shortcodes', array( $this, 'filter_shortcodes' ), 10, 1 ); 1847 1847 … … 1852 1852 } 1853 1853 1854 function filter_shortcodes( $disabled ) {1854 public function filter_shortcodes( $disabled ) { 1855 1855 $disabled[] = 'audio'; 1856 1856 return $disabled; 1857 1857 } 1858 1858 1859 function data_unregistered_shortcodes() {1859 public function data_unregistered_shortcodes() { 1860 1860 return array( 1861 1861 array( … … 1928 1928 * @dataProvider data_primes_vs_quotes 1929 1929 */ 1930 function test_primes_vs_quotes( $input, $output ) {1930 public function test_primes_vs_quotes( $input, $output ) { 1931 1931 return $this->assertSame( $output, wptexturize( $input ) ); 1932 1932 } 1933 1933 1934 function data_primes_vs_quotes() {1934 public function data_primes_vs_quotes() { 1935 1935 return array( 1936 1936 array( … … 1990 1990 * @dataProvider data_primes_quotes_translation 1991 1991 */ 1992 function test_primes_quotes_translation( $input, $output ) {1992 public function test_primes_quotes_translation( $input, $output ) { 1993 1993 add_filter( 'gettext_with_context', array( $this, 'filter_translate2' ), 10, 4 ); 1994 1994 … … 2001 2001 } 2002 2002 2003 function filter_translate2( $translations, $text, $context, $domain ) {2003 public function filter_translate2( $translations, $text, $context, $domain ) { 2004 2004 switch ( $text ) { 2005 2005 case '–': … … 2028 2028 } 2029 2029 2030 function data_primes_quotes_translation() {2030 public function data_primes_quotes_translation() { 2031 2031 return array( 2032 2032 array( … … 2083 2083 * @dataProvider data_whole_posts 2084 2084 */ 2085 function test_pcre_performance( $input ) {2085 public function test_pcre_performance( $input ) { 2086 2086 global $shortcode_tags; 2087 2087 … … 2103 2103 * @ticket 35864 2104 2104 */ 2105 function test_trailing_less_than() {2105 public function test_trailing_less_than() { 2106 2106 $this->assertSame( 'F–oo<', wptexturize( 'F--oo<', true ) ); 2107 2107 } 2108 2108 2109 function data_whole_posts() {2109 public function data_whole_posts() { 2110 2110 require_once DIR_TESTDATA . '/formatting/whole-posts.php'; 2111 2111 return data_whole_posts();
Note: See TracChangeset
for help on using the changeset viewer.