Ticket #39265: formatting.patch
File formatting.patch, 101.0 KB (added by , 4 years ago) |
---|
-
tests/phpunit/tests/formatting/Autop.php
7 7 8 8 /** 9 9 * @ticket 11008 10 * 11 * @covers ::autop 10 12 */ 11 13 function test_first_post() { 12 14 $expected = '<p>Welcome to WordPress! This post contains important information. After you read it, you can make it private to hide it from visitors but still have the information handy for future reference.</p> … … 69 71 * wpautop() Should not alter the contents of "<pre>" elements 70 72 * 71 73 * @ticket 19855 74 * 75 * @covers ::autop 72 76 */ 73 77 public function test_skip_pre_elements() { 74 78 $code = file_get_contents( DIR_TESTDATA . '/formatting/sizzle.js' ); … … 96 100 * wpautop() Should not add <br/> to "<input>" elements 97 101 * 98 102 * @ticket 16456 103 * 104 * @covers ::autop 99 105 */ 100 106 public function test_skip_input_elements() { 101 107 $str = 'Username: <input type="text" id="username" name="username" /><br />Password: <input type="password" id="password1" name="password1" />'; … … 106 112 * wpautop() Should not add <p> and <br/> around <source> and <track> 107 113 * 108 114 * @ticket 26864 115 * 116 * @covers ::autop 109 117 */ 110 118 public function test_source_track_elements() { 111 119 $content = "Paragraph one.\n\n" . … … 192 200 * wpautop() Should not add <p> and <br/> around <param> and <embed> 193 201 * 194 202 * @ticket 26864 203 * 204 * @covers ::autop 195 205 */ 196 206 public function test_param_embed_elements() { 197 207 $content1 = ' … … 271 281 * wpautop() Should not add <br/> to "<select>" or "<option>" elements 272 282 * 273 283 * @ticket 22230 284 * 285 * @covers ::autop 274 286 */ 275 287 public function test_skip_select_option_elements() { 276 288 $str = 'Country: <select id="state" name="state"><option value="1">Alabama</option><option value="2">Alaska</option><option value="3">Arizona</option><option value="4">Arkansas</option><option value="5">California</option></select>'; … … 281 293 * wpautop() should treat block level HTML elements as blocks. 282 294 * 283 295 * @ticket 27268 296 * 297 * @covers ::autop 284 298 */ 285 299 function test_that_wpautop_treats_block_level_elements_as_blocks() { 286 300 $blocks = array( … … 387 401 * wpautop() should treat inline HTML elements as inline. 388 402 * 389 403 * @ticket 27268 404 * 405 * @covers ::autop 390 406 */ 391 407 function test_that_wpautop_treats_inline_elements_as_inline() { 392 408 $inlines = array( … … 437 453 * 438 454 * @ticket 33106 439 455 * @dataProvider data_element_sanity 456 * 457 * @covers ::autop 440 458 */ 441 459 function test_element_sanity( $input, $output ) { 442 460 return $this->assertSame( $output, wpautop( $input ) ); … … 489 507 * wpautop() should not convert line breaks after <br /> tags 490 508 * 491 509 * @ticket 33377 510 * 511 * @covers ::autop 492 512 */ 493 513 function test_that_wpautop_skips_line_breaks_after_br() { 494 514 $content = ' … … 512 532 * wpautop() should convert multiple line breaks into a paragraph regarless of <br /> format 513 533 * 514 534 * @ticket 33377 535 * 536 * @covers ::autop 515 537 */ 516 538 function test_that_wpautop_adds_a_paragraph_after_multiple_br() { 517 539 $content = ' … … 530 552 531 553 /** 532 554 * @ticket 4857 555 * 556 * @covers ::autop 533 557 */ 534 558 function test_that_text_before_blocks_is_peed() { 535 559 $content = 'a<div>b</div>'; … … 545 569 * @uses ::trim 546 570 * 547 571 * @ticket 39307 572 * 573 * @covers ::autop 548 574 */ 549 575 function test_that_wpautop_does_not_add_extra_closing_p_in_figure() { 550 576 $content1 = '<figure><img src="example.jpg" /><figcaption>Caption</figcaption></figure>'; … … 564 590 565 591 /** 566 592 * @ticket 14674 593 * 594 * @covers ::autop 567 595 */ 568 596 function test_the_hr_is_not_peed() { 569 597 $content = 'paragraph1<hr>paragraph2'; … … 576 604 * wpautop() should ignore inline SVG graphics 577 605 * 578 606 * @ticket 9437 607 * 608 * @covers ::autop 579 609 */ 580 610 function test_that_wpautop_ignores_inline_svgs() { 581 611 $content = … … 594 624 * wpautop() should ignore inline scripts 595 625 * 596 626 * @ticket 9437 627 * 628 * @covers ::autop 597 629 */ 598 630 function test_that_wpautop_ignores_inline_scripts() { 599 631 $content = -
tests/phpunit/tests/formatting/balanceTags.php
150 150 /** 151 151 * @ticket 47014 152 152 * @dataProvider supported_traditional_tag_names 153 * 154 * @covers ::balanceTags 153 155 */ 154 156 function test_detects_traditional_tag_names( $tag ) { 155 157 $normalized = strtolower( $tag ); … … 160 162 /** 161 163 * @ticket 47014 162 164 * @dataProvider supported_custom_element_tag_names 165 * 166 * @covers ::balanceTags 163 167 */ 164 168 function test_detects_supported_custom_element_tag_names( $tag ) { 165 169 $this->assertSame( "<$tag>inside</$tag>", balanceTags( "<$tag>inside", true ) ); … … 168 172 /** 169 173 * @ticket 47014 170 174 * @dataProvider invalid_tag_names 175 * 176 * @covers ::balanceTags 171 177 */ 172 178 function test_ignores_invalid_tag_names( $input, $output ) { 173 179 $this->assertSame( $output, balanceTags( $input, true ) ); … … 176 182 /** 177 183 * @ticket 47014 178 184 * @dataProvider unsupported_valid_tag_names 185 * 186 * @covers ::balanceTags 179 187 */ 180 188 function test_ignores_unsupported_custom_tag_names( $tag ) { 181 189 $this->assertSame( "<$tag>inside", balanceTags( "<$tag>inside", true ) ); … … 184 192 /** 185 193 * @ticket 47014 186 194 * @dataProvider supported_invalid_tag_names 195 * 196 * @covers ::balanceTags 187 197 */ 188 198 function test_detects_supported_invalid_tag_names( $tag ) { 189 199 $this->assertSame( "<$tag>inside</$tag>", balanceTags( "<$tag>inside", true ) ); … … 194 204 * 195 205 * @ticket 1597 196 206 * @dataProvider single_tags 207 * 208 * @covers ::balanceTags 197 209 */ 198 210 function test_selfcloses_unclosed_known_single_tags( $tag ) { 199 211 $this->assertSame( "<$tag />", balanceTags( "<$tag>", true ) ); … … 205 217 * 206 218 * @ticket 1597 207 219 * @dataProvider single_tags 220 * 221 * @covers ::balanceTags 208 222 */ 209 223 function test_selfcloses_known_single_tags_having_closing_tag( $tag ) { 210 224 $this->assertSame( "<$tag />", balanceTags( "<$tag></$tag>", true ) ); … … 212 226 213 227 /** 214 228 * @ticket 1597 229 * 230 * @covers ::balanceTags 215 231 */ 216 232 function test_closes_unknown_single_tags_with_closing_tag() { 217 233 … … 236 252 } 237 253 } 238 254 255 /** 256 * @covers ::balanceTags 257 */ 239 258 function test_closes_unclosed_single_tags_having_attributes() { 240 259 $inputs = array( 241 260 '<img src="/images/example.png">', … … 251 270 } 252 271 } 253 272 273 /** 274 * @covers ::balanceTags 275 */ 254 276 function test_allows_validly_closed_single_tags() { 255 277 $inputs = array( 256 278 '<br />', … … 266 288 267 289 /** 268 290 * @dataProvider nestable_tags 291 * 292 * @covers ::balanceTags 269 293 */ 270 294 function test_balances_nestable_tags( $tag ) { 271 295 $inputs = array( … … 284 308 } 285 309 } 286 310 311 /** 312 * @covers ::balanceTags 313 */ 287 314 function test_allows_adjacent_nestable_tags() { 288 315 $inputs = array( 289 316 '<blockquote><blockquote>Example quote</blockquote></blockquote>', … … 300 327 301 328 /** 302 329 * @ticket 20401 330 * 331 * @covers ::balanceTags 303 332 */ 304 333 function test_allows_immediately_nested_object_tags() { 305 334 $object = '<object id="obj1"><param name="param1"/><object id="obj2"><param name="param2"/></object></object>'; … … 306 335 $this->assertSame( $object, balanceTags( $object, true ) ); 307 336 } 308 337 338 /** 339 * @covers ::balanceTags 340 */ 309 341 function test_balances_nested_non_nestable_tags() { 310 342 $inputs = array( 311 343 '<b><b>This is bold</b></b>', … … 321 353 } 322 354 } 323 355 356 /** 357 * @covers ::balanceTags 358 */ 324 359 function test_fixes_improper_closing_tag_sequence() { 325 360 $inputs = array( 326 361 '<p>Here is a <strong class="part">bold <em>and emphasis</p></em></strong>', … … 336 371 } 337 372 } 338 373 374 /** 375 * @covers ::balanceTags 376 */ 339 377 function test_adds_missing_closing_tags() { 340 378 $inputs = array( 341 379 '<b><i>Test</b>', … … 357 395 } 358 396 } 359 397 398 /** 399 * @covers ::balanceTags 400 */ 360 401 function test_removes_extraneous_closing_tags() { 361 402 $inputs = array( 362 403 '<b>Test</b></b>', … … 436 477 * 437 478 * @param string $source Source. 438 479 * @param string $expected Expected. 480 * 481 * @covers ::balanceTags 439 482 */ 440 483 public function test_custom_elements( $source, $expected ) { 441 484 $this->assertSame( $expected, balanceTags( $source, true ) ); -
tests/phpunit/tests/formatting/BlogInfo.php
8 8 /** 9 9 * @dataProvider locales 10 10 * @ticket 28303 11 * 12 * @covers ::get_bloginfo 11 13 */ 12 14 function test_get_bloginfo_language( $test_locale, $expected ) { 13 15 global $locale; … … 35 37 36 38 /** 37 39 * @ticket 27942 40 * 41 * @covers ::get_bloginfo 38 42 */ 39 43 function test_bloginfo_sanitize_option() { 40 44 $old_values = array( -
tests/phpunit/tests/formatting/CapitalPDangit.php
3 3 4 4 /** 5 5 * @group formatting 6 * 7 * @covers ::capital_P_dangit 6 8 */ 7 9 class Tests_Formatting_CapitalPDangit extends WP_UnitTestCase { 8 10 function test_esc_attr_quotes() { -
tests/phpunit/tests/formatting/CleanPre.php
9 9 */ 10 10 class Tests_Formatting_CleanPre extends WP_UnitTestCase { 11 11 12 /** 13 * @covers ::clean_pre 14 */ 12 15 function test_removes_self_closing_br_with_space() { 13 16 $source = 'a b c\n<br />sldfj<br />'; 14 17 $res = 'a b c\nsldfj'; … … 16 19 $this->assertSame( $res, clean_pre( $source ) ); 17 20 } 18 21 22 /** 23 * @covers ::clean_pre 24 */ 19 25 function test_removes_self_closing_br_without_space() { 20 26 $source = 'a b c\n<br/>sldfj<br/>'; 21 27 $res = 'a b c\nsldfj'; … … 22 28 $this->assertSame( $res, clean_pre( $source ) ); 23 29 } 24 30 25 // I don't think this can ever happen in production; 26 // <br> is changed to <br /> elsewhere. Left in because 27 // that replacement shouldn't happen (what if you want 28 // HTML 4 output?). 31 32 /** 33 * I don't think this can ever happen in production; 34 * <br> is changed to <br /> elsewhere. Left in because 35 * that replacement shouldn't happen (what if you want 36 * HTML 4 output?). 37 * 38 * @covers ::clean_pre 39 */ 29 40 function test_removes_html_br() { 30 41 $source = 'a b c\n<br>sldfj<br>'; 31 42 $res = 'a b c\nsldfj'; … … 32 43 $this->assertSame( $res, clean_pre( $source ) ); 33 44 } 34 45 46 /** 47 * @covers ::clean_pre 48 */ 35 49 function test_removes_p() { 36 50 $source = "<p>isn't this exciting!</p><p>oh indeed!</p>"; 37 51 $res = "\nisn't this exciting!\noh indeed!"; -
tests/phpunit/tests/formatting/ConvertInvalidEntries.php
4 4 * @group formatting 5 5 */ 6 6 class Tests_Formatting_ConvertInvalidEntities extends WP_UnitTestCase { 7 8 /** 9 * @covers ::convert_invalid_entities 10 */ 7 11 function test_replaces_windows1252_entities_with_unicode_ones() { 8 12 $input = '‚ƒ„…†‡ˆ‰Š‹Œ‘’“”•–—˜™š›œŸ'; 9 13 $output = '‚ƒ„…†‡ˆ‰Š‹Œ‘’“”•–—˜™š›œŸ'; … … 12 16 13 17 /** 14 18 * @ticket 20503 19 * 20 * @covers ::convert_invalid_entities 15 21 */ 16 22 function test_replaces_latin_letter_z_with_caron() { 17 23 $input = 'Žž'; … … 19 25 $this->assertSame( $output, convert_invalid_entities( $input ) ); 20 26 } 21 27 28 /** 29 * @covers ::convert_invalid_entities 30 */ 22 31 function test_escapes_lone_ampersands() { 23 32 $this->assertSame( 'at&t', convert_chars( 'at&t' ) ); 24 33 } -
tests/phpunit/tests/formatting/date.php
10 10 * Unpatched, this test passes only when Europe/London is not observing DST. 11 11 * 12 12 * @ticket 20328 13 * 14 * @covers ::get_date_from_gmt 13 15 */ 14 16 function test_get_date_from_gmt_outside_of_dst() { 15 17 update_option( 'timezone_string', 'Europe/London' ); … … 22 24 * Unpatched, this test passes only when Europe/London is observing DST. 23 25 * 24 26 * @ticket 20328 27 * 28 * @covers ::get_date_from_gmt 25 29 */ 26 30 function test_get_date_from_gmt_during_dst() { 27 31 update_option( 'timezone_string', 'Europe/London' ); … … 32 36 33 37 /** 34 38 * @ticket 20328 39 * 40 * @covers ::get_gmt_from_date 35 41 */ 36 42 function test_get_gmt_from_date_outside_of_dst() { 37 43 update_option( 'timezone_string', 'Europe/London' ); … … 42 48 43 49 /** 44 50 * @ticket 20328 51 * 52 * @covers ::get_gmt_from_date 45 53 */ 46 54 function test_get_gmt_from_date_during_dst() { 47 55 update_option( 'timezone_string', 'Europe/London' ); … … 52 60 53 61 /** 54 62 * @ticket 34279 63 * 64 * @covers ::get_date_from_gmt 65 * 55 66 */ 56 67 function test_get_date_and_time_from_gmt_no_timezone() { 57 68 $local = '2012-01-01 12:34:56'; … … 61 72 62 73 /** 63 74 * @ticket 34279 75 * 76 * @covers ::get_gmt_from_date 64 77 */ 65 78 function test_get_gmt_from_date_no_timezone() { 66 79 $gmt = '2012-12-01 00:00:00'; … … 70 83 71 84 /** 72 85 * @ticket 34279 86 * 87 * @covers ::get_gmt_from_date 73 88 */ 74 89 function test_get_gmt_from_date_short_date() { 75 90 update_option( 'timezone_string', 'Europe/London' ); … … 80 95 81 96 /** 82 97 * @ticket 34279 98 * 99 * @covers ::get_gmt_from_date 83 100 */ 84 101 function test_get_gmt_from_date_string_date() { 85 102 update_option( 'timezone_string', 'Europe/London' ); … … 90 107 91 108 /** 92 109 * @ticket 34279 110 * 111 * @covers ::get_gmt_from_date 93 112 */ 94 113 function test_get_gmt_from_date_string_date_no_timezone() { 95 114 $local = 'now'; … … 101 120 * @ticket 31809 102 121 * 103 122 * @dataProvider timezone_provider 123 * 124 * @covers ::get_gmt_from_date 104 125 */ 105 126 public function test_gmt_from_date_correct_time( $timezone_string, $gmt_offset ) { 106 127 update_option( 'timezone_string', $timezone_string ); … … 117 138 * @ticket 31809 118 139 * 119 140 * @dataProvider timezone_provider 141 * 142 * @covers ::get_date_from_gmt 120 143 */ 121 144 public function test_date_from_gmt_correct_time( $timezone_string, $gmt_offset ) { 122 145 update_option( 'timezone_string', $timezone_string ); … … 133 156 * @ticket 31809 134 157 * 135 158 * @dataProvider timezone_provider 159 * 160 * @covers ::iso8601_to_datetime 136 161 */ 137 162 public function test_is8601_to_datetime_correct_time( $timezone_string, $gmt_offset ) { 138 163 update_option( 'timezone_string', $timezone_string ); -
tests/phpunit/tests/formatting/Emoji.php
11 11 12 12 /** 13 13 * @ticket 36525 14 * 15 * @covers ::_print_emoji_detection_script 14 16 */ 15 17 public function test_unfiltered_emoji_cdns() { 16 18 $output = get_echo( '_print_emoji_detection_script' ); … … 25 27 26 28 /** 27 29 * @ticket 36525 30 * 31 * @covers ::_print_emoji_detection_script 28 32 */ 29 33 public function test_filtered_emoji_svn_cdn() { 30 34 $filtered_svn_cdn = $this->_filtered_emoji_svn_cdn(); … … 46 50 47 51 /** 48 52 * @ticket 36525 53 * 54 * @covers ::_print_emoji_detection_script 49 55 */ 50 56 public function test_filtered_emoji_png_cdn() { 51 57 $filtered_png_cdn = $this->_filtered_emoji_png_cdn(); … … 63 69 64 70 /** 65 71 * @ticket 41501 72 * 73 * @covers ::_wp_emoji_list 66 74 */ 67 75 public function test_wp_emoji_list_returns_data() { 68 76 $default = _wp_emoji_list(); … … 107 115 /** 108 116 * @ticket 35293 109 117 * @dataProvider data_wp_encode_emoji 118 * 119 * @covers ::wp_encode_emoji 110 120 */ 111 121 public function test_wp_encode_emoji( $emoji, $expected ) { 112 122 $this->assertSame( $expected, wp_encode_emoji( $emoji ) ); … … 142 152 /** 143 153 * @ticket 35293 144 154 * @dataProvider data_wp_staticize_emoji 155 * 156 * @covers ::wp_staticize_emoji 145 157 */ 146 158 public function test_wp_staticize_emoji( $emoji, $expected ) { 147 159 $this->assertSame( $expected, wp_staticize_emoji( $emoji ) ); -
tests/phpunit/tests/formatting/ent2ncr.php
6 6 class Tests_Formatting_Ent2NCR extends WP_UnitTestCase { 7 7 /** 8 8 * @dataProvider entities 9 * 10 * @covers ::ent2ncr 9 11 */ 10 12 function test_converts_named_entities_to_numeric_character_references( $entity, $ncr ) { 11 13 $entity = '&' . $entity . ';'; -
tests/phpunit/tests/formatting/EscAttr.php
4 4 * @group formatting 5 5 */ 6 6 class Tests_Formatting_EscAttr extends WP_UnitTestCase { 7 /** 8 * @covers ::esc_attr 9 */ 7 10 function test_esc_attr_quotes() { 8 11 $attr = '"double quotes"'; 9 12 $this->assertSame( '"double quotes"', esc_attr( $attr ) ); … … 24 27 $attr = "'mixed' " . '"quotes"'; 25 28 $this->assertSame( ''mixed' "quotes"', esc_attr( esc_attr( $attr ) ) ); 26 29 } 27 30 /** 31 * @covers ::esc_attr 32 */ 28 33 function test_esc_attr_amp() { 29 34 $out = esc_attr( 'foo & bar &baz; ' ); 30 35 $this->assertSame( 'foo & bar &baz; ', $out ); -
tests/phpunit/tests/formatting/EscHtml.php
4 4 * @group formatting 5 5 */ 6 6 class Tests_Formatting_EscHtml extends WP_UnitTestCase { 7 8 /** 9 * @covers ::esc_html 10 */ 7 11 function test_esc_html_basics() { 8 12 // Simple string. 9 13 $html = 'The quick brown fox.'; … … 20 24 $this->assertSame( $escaped, esc_html( $html ) ); 21 25 } 22 26 27 /** 28 * @covers ::esc_html 29 */ 23 30 function test_escapes_ampersands() { 24 31 $source = 'penn & teller & at&t'; 25 32 $res = 'penn & teller & at&t'; … … 26 33 $this->assertSame( $res, esc_html( $source ) ); 27 34 } 28 35 36 /** 37 * @covers ::esc_html 38 */ 29 39 function test_escapes_greater_and_less_than() { 30 40 $source = 'this > that < that <randomhtml />'; 31 41 $res = 'this > that < that <randomhtml />'; … … 32 42 $this->assertSame( $res, esc_html( $source ) ); 33 43 } 34 44 45 /** 46 * @covers ::esc_html 47 */ 35 48 function test_ignores_existing_entities() { 36 49 $source = '& £ " &'; 37 50 $res = '& £ " &'; -
tests/phpunit/tests/formatting/EscTextarea.php
12 12 /* 13 13 * Only fails in PHP 5.4 onwards 14 14 * @ticket 23688 15 * 16 * @covers ::esc_textarea 15 17 */ 16 18 function test_esc_textarea_charset_iso_8859_1() { 17 19 add_filter( 'pre_option_blog_charset', array( $this, '_charset_iso_8859_1' ) ); … … 26 28 27 29 /* 28 30 * @ticket 23688 31 * 32 * @covers ::esc_textarea 29 33 */ 30 34 function test_esc_textarea_charset_utf_8() { 31 35 add_filter( 'pre_option_blog_charset', array( $this, '_charset_utf_8' ) ); -
tests/phpunit/tests/formatting/EscUrl.php
7 7 8 8 /** 9 9 * @ticket 23605 10 * 11 * @covers ::esc_url 10 12 */ 11 13 function test_spaces() { 12 14 $this->assertSame( 'http://example.com/Mr%20WordPress', esc_url( 'http://example.com/Mr WordPress' ) ); … … 19 21 $this->assertSame( 'http://example.com/?foo=one%20two%20three&bar=four', esc_url( 'http://example.com/?foo=one%20two%20three&bar=four' ) ); 20 22 } 21 23 24 /** 25 * 26 * @covers ::esc_url 27 */ 22 28 function test_bad_characters() { 23 29 $this->assertSame( 'http://example.com/watchthelinefeedgo', esc_url( 'http://example.com/watchthelinefeed%0Ago' ) ); 24 30 $this->assertSame( 'http://example.com/watchthelinefeedgo', esc_url( 'http://example.com/watchthelinefeed%0ago' ) ); … … 33 39 $this->assertSame( 'http://example.com/', esc_url( 'http://example.com/%0%0%0ADa' ) ); 34 40 } 35 41 42 /** 43 * 44 * @covers ::esc_url 45 */ 36 46 function test_relative() { 37 47 $this->assertSame( '/example.php', esc_url( '/example.php' ) ); 38 48 $this->assertSame( 'example.php', esc_url( 'example.php' ) ); … … 40 50 $this->assertSame( '?foo=bar', esc_url( '?foo=bar' ) ); 41 51 } 42 52 53 /** 54 * 55 * @covers ::esc_url 56 * @covers ::esc_url_raw 57 */ 43 58 function test_all_url_parts() { 44 59 $url = 'https://user:pass@host.example.com:1234/path;p=1?query=2&r[]=3#fragment'; 45 60 … … 60 75 $this->assertSame( 'https://user:pass@host.example.com:1234/path;p=1?query=2&r%5B%5D=3#fragment', esc_url( $url ) ); 61 76 } 62 77 78 /** 79 * 80 * @covers ::esc_url 81 */ 63 82 function test_bare() { 64 83 $this->assertSame( 'http://example.com?foo', esc_url( 'example.com?foo' ) ); 65 84 $this->assertSame( 'http://example.com', esc_url( 'example.com' ) ); … … 68 87 $this->assertSame( 'http://баба.org/баба', esc_url( 'баба.org/баба' ) ); 69 88 } 70 89 90 /** 91 * 92 * @covers ::esc_url 93 * @covers ::esc_url_raw 94 */ 71 95 function test_encoding() { 72 96 $this->assertSame( 'http://example.com?foo=1&bar=2', esc_url_raw( 'http://example.com?foo=1&bar=2' ) ); 73 97 $this->assertSame( 'http://example.com?foo=1&bar=2', esc_url_raw( 'http://example.com?foo=1&bar=2' ) ); … … 81 105 $this->assertSame( "http://example.com?url={$param}", esc_url( "http://example.com?url={$param}" ) ); 82 106 } 83 107 108 /** 109 * 110 * @covers ::esc_url 111 * @covers ::esc_url_raw 112 */ 84 113 function test_protocol() { 85 114 $this->assertSame( 'http://example.com', esc_url( 'http://example.com' ) ); 86 115 $this->assertSame( '', esc_url( 'nasty://example.com/' ) ); … … 145 174 146 175 /** 147 176 * @ticket 23187 177 * 178 * @covers ::esc_url 148 179 */ 149 180 function test_protocol_case() { 150 181 $this->assertSame( 'http://example.com', esc_url( 'HTTP://example.com' ) ); … … 151 182 $this->assertSame( 'http://example.com', esc_url( 'Http://example.com' ) ); 152 183 } 153 184 185 /** 186 * 187 * @covers ::esc_url 188 */ 154 189 function test_display_extras() { 155 190 $this->assertSame( 'http://example.com/'quoted'', esc_url( 'http://example.com/\'quoted\'' ) ); 156 191 $this->assertSame( 'http://example.com/\'quoted\'', esc_url( 'http://example.com/\'quoted\'', null, 'notdisplay' ) ); 157 192 } 158 193 194 /** 195 * 196 * @covers ::esc_url 197 */ 159 198 function test_non_ascii() { 160 199 $this->assertSame( 'http://example.org/баба', esc_url( 'http://example.org/баба' ) ); 161 200 $this->assertSame( 'http://баба.org/баба', esc_url( 'http://баба.org/баба' ) ); … … 162 201 $this->assertSame( 'http://müller.com/', esc_url( 'http://müller.com/' ) ); 163 202 } 164 203 204 /** 205 * 206 * @covers ::esc_url 207 */ 165 208 function test_feed() { 166 209 $this->assertSame( '', esc_url( 'feed:javascript:alert(1)' ) ); 167 210 $this->assertSame( '', esc_url( 'feed:javascript:feed:alert(1)' ) ); … … 172 215 173 216 /** 174 217 * @ticket 16859 218 * 219 * @covers ::esc_url 175 220 */ 176 221 function test_square_brackets() { 177 222 $this->assertSame( '/example.php?one%5B%5D=two', esc_url( '/example.php?one[]=two' ) ); … … 187 232 188 233 /** 189 234 * Courtesy of http://blog.lunatech.com/2009/02/03/what-every-web-developer-must-know-about-url-encoding 235 * 236 * @covers ::esc_url_raw 190 237 */ 191 238 function test_reserved_characters() { 192 239 $url = "http://example.com/:@-._~!$&'()*+,=;:@-._~!$&'()*+,=:@-._~!$&'()*+,==?/?:@-._~!$%27()*+,;=/?:@-._~!$%27()*+,;==#/?:@-._~!$&'()*+,;="; … … 195 242 196 243 /** 197 244 * @ticket 21974 245 * 246 * @covers ::esc_url 198 247 */ 199 248 function test_protocol_relative_with_colon() { 200 249 $this->assertSame( '//example.com/foo?foo=abc:def', esc_url( '//example.com/foo?foo=abc:def' ) ); … … 202 251 203 252 /** 204 253 * @ticket 31632 254 * 255 * @covers ::esc_url 205 256 */ 206 257 function test_mailto_with_newline() { 207 258 $body = <<<EOT … … 217 268 218 269 /** 219 270 * @ticket 31632 271 * 272 * @covers ::esc_url 220 273 */ 221 274 function test_mailto_in_http_url_with_newline() { 222 275 $body = <<<EOT … … 232 285 233 286 /** 234 287 * @ticket 23605 288 * 289 * @covers ::esc_url 235 290 */ 236 291 function test_mailto_with_spaces() { 237 292 $body = 'Hi there, I thought you might want to sign up for this newsletter'; … … 243 298 244 299 /** 245 300 * @ticket 28015 301 * 302 * @covers ::esc_url_raw 246 303 */ 247 304 function test_invalid_charaters() { 248 305 $this->assertEmpty( esc_url_raw( '"^<>{}`' ) ); … … 250 307 251 308 /** 252 309 * @ticket 34202 310 * 311 * @covers ::esc_url 253 312 */ 254 313 function test_ipv6_hosts() { 255 314 $this->assertSame( '//[::127.0.0.1]', esc_url( '//[::127.0.0.1]' ) ); -
tests/phpunit/tests/formatting/EscXml.php
11 11 * 12 12 * @param string $source The source string to be escaped. 13 13 * @param string $expected The expected escaped value of `$source`. 14 * 15 * @covers ::esc_xml 14 16 */ 15 17 public function test_esc_xml_basics( $source, $expected ) { 16 18 $actual = esc_xml( $source ); … … 45 47 ); 46 48 } 47 49 50 /** 51 * 52 * @covers ::esc_xml 53 */ 48 54 public function test_escapes_ampersands() { 49 55 $source = 'penn & teller & at&t'; 50 56 $expected = 'penn & teller & at&t'; … … 52 58 $this->assertSame( $expected, $actual ); 53 59 } 54 60 61 /** 62 * 63 * @covers ::esc_xml 64 */ 55 65 public function test_escapes_greater_and_less_than() { 56 66 $source = 'this > that < that <randomhtml />'; 57 67 $expected = 'this > that < that <randomhtml />'; … … 59 69 $this->assertSame( $expected, $actual ); 60 70 } 61 71 72 /** 73 * 74 * @covers ::esc_xml 75 */ 62 76 public function test_escapes_html_named_entities() { 63 77 $source = 'this & is a … followed by › and more and a &nonexistent; entity'; 64 78 $expected = 'this & is a … followed by › and more and a &nonexistent; entity'; … … 66 80 $this->assertSame( $expected, $actual ); 67 81 } 68 82 83 /** 84 * 85 * @covers ::esc_xml 86 */ 69 87 public function test_ignores_existing_entities() { 70 88 $source = '& £ " &'; 71 89 // note that _wp_specialchars() strips leading 0's from numeric character references. … … 81 99 * 82 100 * @param string $source The source string to be escaped. 83 101 * @param string $expected The expected escaped value of `$source`. 102 * 103 * @covers ::esc_xml 84 104 */ 85 105 public function test_ignores_cdata_sections( $source, $expected ) { 86 106 $actual = esc_xml( $source ); -
tests/phpunit/tests/formatting/ExcerptRemoveBlocks.php
22 22 <!-- wp:column --> 23 23 <div class="wp-block-column"> 24 24 <!-- wp:archives {"displayAsDropdown":false,"showPostCounts":false} /--> 25 25 26 26 <!-- wp:paragraph --> 27 27 <p>paragraph inside column</p> 28 28 <!-- /wp:paragraph --> … … 40 40 41 41 42 42 <p>paragraph inside column</p> 43 43 44 44 '; 45 45 46 46 /** … … 91 91 * Tests excerpt_remove_blocks(). 92 92 * 93 93 * @ticket 46133 94 * 95 * @covers ::excerpt_remove_blocks 94 96 */ 95 97 function test_excerpt_remove_blocks() { 96 98 // Simple dynamic block.. … … 116 118 * `the_content` gets applied, just like shortcodes. 117 119 * 118 120 * @ticket 46133 121 * 122 * @covers ::do_blocks 119 123 */ 120 124 function test_excerpt_infinite_loop() { 121 125 $query = new WP_Query( -
tests/phpunit/tests/formatting/GetUrlInContent.php
43 43 * Validate the get_url_in_content function 44 44 * 45 45 * @dataProvider get_input_output 46 * 47 * @covers ::get_url_in_content 46 48 */ 47 49 function test_get_url_in_content( $in_str, $exp_str ) { 48 50 $this->assertSame( $exp_str, get_url_in_content( $in_str ) ); -
tests/phpunit/tests/formatting/HtmlExcerpt.php
4 4 * @group formatting 5 5 */ 6 6 class Tests_Formatting_HtmlExcerpt extends WP_UnitTestCase { 7 8 /** 9 * @covers ::wp_html_excerpt 10 */ 7 11 function test_simple() { 8 12 $this->assertSame( 'Baba', wp_html_excerpt( 'Baba told me not to come', 4 ) ); 9 13 } 14 15 /** 16 * @covers ::wp_html_excerpt 17 */ 10 18 function test_html() { 11 19 $this->assertSame( 'Baba', wp_html_excerpt( "<a href='http://baba.net/'>Baba</a> told me not to come", 4 ) ); 12 20 } 21 22 /** 23 * @covers ::wp_html_excerpt 24 */ 13 25 function test_entities() { 14 26 $this->assertSame( 'Baba', wp_html_excerpt( 'Baba & Dyado', 8 ) ); 15 27 $this->assertSame( 'Baba', wp_html_excerpt( 'Baba & Dyado', 8 ) ); -
tests/phpunit/tests/formatting/HumanTimeDiff.php
10 10 * @group formatting 11 11 * @ticket 38773 12 12 * @dataProvider data_test_human_time_diff 13 * 14 * @covers ::human_time_diff 13 15 */ 14 16 function test_human_time_diff( $expected, $stopdate, $message ) { 15 17 $startdate = new DateTime( '2016-01-01 12:00:00' ); -
tests/phpunit/tests/formatting/IsEmail.php
4 4 * @group formatting 5 5 */ 6 6 class Tests_Formatting_IsEmail extends WP_UnitTestCase { 7 8 /** 9 * @covers ::is_email 10 */ 7 11 function test_returns_the_email_address_if_it_is_valid() { 8 12 $data = array( 9 13 'bob@example.com', … … 17 21 } 18 22 } 19 23 24 /** 25 * @covers ::is_email 26 */ 20 27 function test_returns_false_if_given_an_invalid_email_address() { 21 28 $data = array( 22 29 'khaaaaaaaaaaaaaaan!', -
tests/phpunit/tests/formatting/isoDescrambler.php
7 7 /* 8 8 * Decodes text in RFC2047 "Q"-encoding, e.g. 9 9 * =?iso-8859-1?q?this=20is=20some=20text?= 10 * 11 * @covers ::wp_iso_descrambler 10 12 */ 11 13 function test_decodes_iso_8859_1_rfc2047_q_encoding() { 12 14 $this->assertSame( 'this is some text', wp_iso_descrambler( '=?iso-8859-1?q?this=20is=20some=20text?=' ) ); -
tests/phpunit/tests/formatting/JSEscape.php
4 4 * @group formatting 5 5 */ 6 6 class Tests_Formatting_JSEscape extends WP_UnitTestCase { 7 8 /** 9 * @covers ::esc_js 10 */ 7 11 function test_js_escape_simple() { 8 12 $out = esc_js( 'foo bar baz();' ); 9 13 $this->assertSame( 'foo bar baz();', $out ); 10 14 } 11 15 16 /** 17 * @covers ::esc_js 18 */ 12 19 function test_js_escape_quotes() { 13 20 $out = esc_js( 'foo "bar" \'baz\'' ); 14 21 // Does it make any sense to change " into "? Why not \"? … … 15 22 $this->assertSame( "foo "bar" \'baz\'", $out ); 16 23 } 17 24 25 /** 26 * @covers ::esc_js 27 */ 18 28 function test_js_escape_backslash() { 19 29 $bs = '\\'; 20 30 $out = esc_js( 'foo ' . $bs . 't bar ' . $bs . $bs . ' baz' ); … … 22 32 $this->assertSame( 'foo t bar ' . $bs . $bs . ' baz', $out ); 23 33 } 24 34 35 /** 36 * @covers ::esc_js 37 */ 25 38 function test_js_escape_amp() { 26 39 $out = esc_js( 'foo & bar &baz; ' ); 27 40 $this->assertSame( 'foo & bar &baz; ', $out ); 28 41 } 29 42 43 /** 44 * @covers ::esc_js 45 */ 30 46 function test_js_escape_quote_entity() { 31 47 $out = esc_js( 'foo ' bar ' baz &' ); 32 48 $this->assertSame( "foo \\' bar \\' baz &", $out ); 33 49 } 34 50 51 /** 52 * @covers ::esc_js 53 */ 35 54 function test_js_no_carriage_return() { 36 55 $out = esc_js( "foo\rbar\nbaz\r" ); 37 56 // \r is stripped. … … 38 57 $this->assertSame( "foobar\\nbaz", $out ); 39 58 } 40 59 60 /** 61 * @covers ::esc_js 62 */ 41 63 function test_js_escape_rn() { 42 64 $out = esc_js( "foo\r\nbar\nbaz\r\n" ); 43 65 // \r is stripped. -
tests/phpunit/tests/formatting/LikeEscape.php
7 7 /** 8 8 * @ticket 10041 9 9 * @expectedDeprecated like_escape 10 * 11 * @covers ::like_escape 10 12 */ 11 13 function test_like_escape() { 12 14 -
tests/phpunit/tests/formatting/LinksAddTarget.php
95 95 * Validate the normalize_whitespace function 96 96 * 97 97 * @dataProvider get_input_output 98 * 99 * @covers ::links_add_target 98 100 */ 99 101 function test_normalize_whitespace( $content, $target, $tags, $exp_str ) { 100 102 if ( true === is_null( $target ) ) { -
tests/phpunit/tests/formatting/MakeClickable.php
4 4 * @group formatting 5 5 */ 6 6 class Tests_Formatting_MakeClickable extends WP_UnitTestCase { 7 8 /** 9 * @covers ::make_clickable 10 */ 7 11 function test_mailto_xss() { 8 12 $in = 'testzzz@"STYLE="behavior:url(\'#default#time2\')"onBegin="alert(\'refresh-XSS\')"'; 9 13 $this->assertSame( $in, make_clickable( $in ) ); 10 14 } 11 15 16 /** 17 * @covers ::make_clickable 18 */ 12 19 function test_valid_mailto() { 13 20 $valid_emails = array( 14 21 'foo@example.com', … … 22 29 } 23 30 } 24 31 32 /** 33 * @covers ::make_clickable 34 */ 25 35 function test_invalid_mailto() { 26 36 $invalid_emails = array( 27 37 'foo', … … 39 49 /** 40 50 * Tests that make_clickable() will not link trailing periods, commas, 41 51 * and (semi-)colons in URLs with protocol (i.e. http://wordpress.org). 52 * 53 * @covers ::make_clickable 42 54 */ 43 55 function test_strip_trailing_with_protocol() { 44 56 $urls_before = array( … … 66 78 /** 67 79 * Tests that make_clickable() will not link trailing periods, commas, 68 80 * and (semi-)colons in URLs with protocol (i.e. http://wordpress.org). 81 * 82 * @covers ::make_clickable 69 83 */ 70 84 function test_strip_trailing_with_protocol_nothing_afterwards() { 71 85 $urls_before = array( … … 95 109 /** 96 110 * Tests that make_clickable() will not link trailing periods, commas, 97 111 * and (semi-)colons in URLs without protocol (i.e. www.wordpress.org). 112 * 113 * @covers ::make_clickable 98 114 */ 99 115 function test_strip_trailing_without_protocol() { 100 116 $urls_before = array( … … 122 138 /** 123 139 * Tests that make_clickable() will not link trailing periods, commas, 124 140 * and (semi-)colons in URLs without protocol (i.e. www.wordpress.org). 141 * 142 * @covers ::make_clickable 125 143 */ 126 144 function test_strip_trailing_without_protocol_nothing_afterwards() { 127 145 $urls_before = array( … … 148 166 149 167 /** 150 168 * @ticket 4570 169 * 170 * @covers ::make_clickable 151 171 */ 152 172 function test_iri() { 153 173 $urls_before = array( … … 167 187 168 188 /** 169 189 * @ticket 10990 190 * 191 * @covers ::make_clickable 170 192 */ 171 193 function test_brackets_in_urls() { 172 194 $urls_before = array( … … 206 228 * Based on real comments which were incorrectly linked. 207 229 * 208 230 * @ticket 11211 231 * 232 * @covers ::make_clickable 209 233 */ 210 234 function test_real_world_examples() { 211 235 $urls_before = array( … … 227 251 228 252 /** 229 253 * @ticket 14993 254 * 255 * @covers ::make_clickable 230 256 */ 231 257 function test_twitter_hash_bang() { 232 258 $urls_before = array( … … 244 270 } 245 271 } 246 272 273 /** 274 * @covers ::make_clickable 275 */ 247 276 function test_wrapped_in_angles() { 248 277 $before = array( 249 278 'URL wrapped in angle brackets <http://example.com/>', … … 260 289 } 261 290 } 262 291 292 /** 293 * @covers ::make_clickable 294 */ 263 295 function test_preceded_by_punctuation() { 264 296 $before = array( 265 297 'Comma then URL,http://example.com/', … … 282 314 } 283 315 } 284 316 317 /** 318 * @covers ::make_clickable 319 */ 285 320 function test_dont_break_attributes() { 286 321 $urls_before = array( 287 322 "<img src='http://trunk.domain/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley'>", … … 308 343 309 344 /** 310 345 * @ticket 23756 346 * 347 * @covers ::make_clickable 311 348 */ 312 349 function test_no_links_inside_pre_or_code() { 313 350 $before = array( … … 349 386 350 387 /** 351 388 * @ticket 16892 389 * 390 * @covers ::make_clickable 352 391 */ 353 392 function test_click_inside_html() { 354 393 $urls_before = array( … … 364 403 } 365 404 } 366 405 406 /** 407 * @covers ::make_clickable 408 */ 367 409 function test_no_links_within_links() { 368 410 $in = array( 369 411 'Some text with a link <a href="http://example.com">http://example.com</a>', … … 376 418 377 419 /** 378 420 * @ticket 16892 421 * 422 * @covers ::make_clickable 379 423 */ 380 424 function test_no_segfault() { 381 425 $in = str_repeat( 'http://example.com/2011/03/18/post-title/', 256 ); … … 385 429 386 430 /** 387 431 * @ticket 19028 432 * 433 * @covers ::make_clickable 388 434 */ 389 435 function test_line_break_in_existing_clickable_link() { 390 436 $html = "<a … … 395 441 /** 396 442 * @ticket 30162 397 443 * @dataProvider data_script_and_style_tags 444 * 445 * @covers ::make_clickable 398 446 */ 399 447 public function test_dont_link_script_and_style_tags( $tag ) { 400 448 $this->assertSame( $tag, make_clickable( $tag ) ); … … 420 468 /** 421 469 * @ticket 48022 422 470 * @dataProvider data_add_rel_ugc_in_comments 471 * 472 * @covers ::make_clickable 423 473 */ 424 474 public function test_add_rel_ugc_in_comments( $content, $expected ) { 425 475 $comment_id = self::factory()->comment->create( -
tests/phpunit/tests/formatting/MapDeep.php
6 6 */ 7 7 class Tests_Formatting_MapDeep extends WP_UnitTestCase { 8 8 9 /** 10 * @covers ::map_deep 11 */ 9 12 public function test_map_deep_with_any_function_over_empty_array_should_return_empty_array() { 10 13 $this->assertSame( array(), map_deep( array(), array( $this, 'append_baba' ) ) ); 11 14 } 12 15 16 /** 17 * @covers ::map_deep 18 */ 13 19 public function test_map_deep_should_map_each_element_of_array_one_level_deep() { 14 20 $this->assertSame( 15 21 array( … … 26 32 ); 27 33 } 28 34 35 /** 36 * @covers ::map_deep 37 */ 29 38 public function test_map_deep_should_map_each_element_of_array_two_levels_deep() { 30 39 $this->assertSame( 31 40 array( … … 46 55 ); 47 56 } 48 57 58 /** 59 * @covers ::map_deep 60 */ 49 61 public function test_map_deep_should_map_each_object_element_of_an_array() { 50 62 $this->assertEquals( 51 63 array( … … 66 78 ); 67 79 } 68 80 81 /** 82 * @covers ::map_deep 83 */ 69 84 public function test_map_deep_should_apply_the_function_to_a_string() { 70 85 $this->assertSame( 'xbaba', map_deep( 'x', array( $this, 'append_baba' ) ) ); 71 86 } 72 87 88 /** 89 * @covers ::map_deep 90 */ 73 91 public function test_map_deep_should_apply_the_function_to_an_integer() { 74 92 $this->assertSame( '5baba', map_deep( 5, array( $this, 'append_baba' ) ) ); 75 93 } 76 94 95 /** 96 * @covers ::map_deep 97 */ 77 98 public function test_map_deep_should_map_each_property_of_an_object() { 78 99 $this->assertEquals( 79 100 (object) array( … … 90 111 ); 91 112 } 92 113 114 /** 115 * @covers ::map_deep 116 */ 93 117 public function test_map_deep_should_map_each_array_property_of_an_object() { 94 118 $this->assertEquals( 95 119 (object) array( … … 110 134 ); 111 135 } 112 136 137 /** 138 * @covers ::map_deep 139 */ 113 140 public function test_map_deep_should_map_each_object_property_of_an_object() { 114 141 $this->assertEquals( 115 142 (object) array( … … 132 159 133 160 /** 134 161 * @ticket 35058 162 * 163 * @covers ::map_deep 135 164 */ 136 165 public function test_map_deep_should_map_object_properties_passed_by_reference() { 137 166 $object_a = (object) array( 'var0' => 'a' ); … … 150 179 151 180 /** 152 181 * @ticket 35058 182 * 183 * @covers ::map_deep 153 184 */ 154 185 public function test_map_deep_should_map_array_elements_passed_by_reference() { 155 186 $array_a = array( 'var0' => 'a' ); -
tests/phpunit/tests/formatting/NormalizeWhitespace.php
45 45 * Validate the normalize_whitespace function 46 46 * 47 47 * @dataProvider get_input_output 48 * 49 * @covers ::normalize_whitespace 48 50 */ 49 51 function test_normalize_whitespace( $in_str, $exp_str ) { 50 52 $this->assertSame( $exp_str, normalize_whitespace( $in_str ) ); -
tests/phpunit/tests/formatting/redirect.php
6 6 * @group redirect 7 7 */ 8 8 class Tests_Formatting_Redirect extends WP_UnitTestCase { 9 9 10 function setUp() { 10 11 parent::setUp(); 11 12 add_filter( 'home_url', array( $this, 'home_url' ) ); … … 27 28 * 28 29 * @param string $location The path or URL to redirect to. 29 30 * @param int $status HTTP response status code to use. 31 * 32 * @covers ::wp_redirect 30 33 */ 31 34 public function test_wp_redirect_bad_status_code( $location, $status ) { 32 35 $this->expectException( 'WPDieException' ); … … 46 49 ); 47 50 } 48 51 52 /** 53 * @covers ::wp_sanitize_redirect 54 */ 49 55 function test_wp_sanitize_redirect() { 50 56 $this->assertSame( 'http://example.com/watchthelinefeedgo', wp_sanitize_redirect( 'http://example.com/watchthelinefeed%0Ago' ) ); 51 57 $this->assertSame( 'http://example.com/watchthelinefeedgo', wp_sanitize_redirect( 'http://example.com/watchthelinefeed%0ago' ) ); … … 64 70 65 71 /** 66 72 * @group 36998 73 * 74 * @covers ::wp_sanitize_redirect 67 75 */ 68 76 function test_wp_sanitize_redirect_should_encode_spaces() { 69 77 $this->assertSame( 'http://example.com/test%20spaces', wp_sanitize_redirect( 'http://example.com/test%20spaces' ) ); … … 72 80 73 81 /** 74 82 * @dataProvider valid_url_provider 83 * 84 * @covers ::wp_validate_redirect 75 85 */ 76 86 function test_wp_validate_redirect_valid_url( $url, $expected ) { 77 87 $this->assertSame( $expected, wp_validate_redirect( $url ) ); … … 79 89 80 90 /** 81 91 * @dataProvider invalid_url_provider 92 * 93 * @covers ::wp_validate_redirect 82 94 */ 83 95 function test_wp_validate_redirect_invalid_url( $url ) { 84 96 $this->assertEquals( false, wp_validate_redirect( $url, false ) ); … … 171 183 /** 172 184 * @ticket 47980 173 185 * @dataProvider relative_url_provider 186 * 187 * @covers ::wp_validate_redirect 174 188 */ 175 189 function test_wp_validate_redirect_relative_url( $current_uri, $url, $expected ) { 176 190 // Backup the global. -
tests/phpunit/tests/formatting/RemoveAccents.php
4 4 * @group formatting 5 5 */ 6 6 class Tests_Formatting_RemoveAccents extends WP_UnitTestCase { 7 8 /** 9 * @covers ::remove_accents 10 */ 7 11 public function test_remove_accents_simple() { 8 12 $this->assertSame( 'abcdefghijkl', remove_accents( 'abcdefghijkl' ) ); 9 13 } … … 10 14 11 15 /** 12 16 * @ticket 9591 17 * 18 * @covers ::remove_accents 13 19 */ 14 20 public function test_remove_accents_latin1_supplement() { 15 21 $input = 'ªºÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ'; … … 18 24 $this->assertSame( $output, remove_accents( $input ), 'remove_accents replaces Latin-1 Supplement' ); 19 25 } 20 26 27 /** 28 * @covers ::remove_accents 29 */ 21 30 public function test_remove_accents_latin_extended_a() { 22 31 $input = 'ĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſ'; 23 32 $output = 'AaAaAaCcCcCcCcDdDdEeEeEeEeEeGgGgGgGgHhHhIiIiIiIiIiIJijJjKkkLlLlLlLlLlNnNnNnnNnOoOoOoOEoeRrRrRrSsSsSsSsTtTtTtUuUuUuUuUuUuWwYyYZzZzZzs'; … … 25 34 $this->assertSame( $output, remove_accents( $input ), 'remove_accents replaces Latin Extended A' ); 26 35 } 27 36 37 /** 38 * @covers ::remove_accents 39 */ 28 40 public function test_remove_accents_latin_extended_b() { 29 41 $this->assertSame( 'SsTt', remove_accents( 'ȘșȚț' ), 'remove_accents replaces Latin Extended B' ); 30 42 } 31 43 44 /** 45 * @covers ::remove_accents 46 */ 32 47 public function test_remove_accents_euro_pound_signs() { 33 48 $this->assertSame( 'E', remove_accents( '€' ), 'remove_accents replaces euro sign' ); 34 49 $this->assertSame( '', remove_accents( '£' ), 'remove_accents replaces pound sign' ); 35 50 } 36 51 52 /** 53 * @covers ::remove_accents 54 */ 37 55 public function test_remove_accents_iso8859() { 38 56 // File is Latin1-encoded. 39 57 $file = DIR_TESTDATA . '/formatting/remove_accents.01.input.txt'; … … 46 64 47 65 /** 48 66 * @ticket 17738 67 * 68 * @covers ::remove_accents 49 69 */ 50 70 public function test_remove_accents_vowels_diacritic() { 51 71 // Vowels with diacritic. … … 65 85 66 86 /** 67 87 * @ticket 20772 88 * 89 * @covers ::remove_accents 68 90 */ 69 91 public function test_remove_accents_hanyu_pinyin() { 70 92 // Vowels with diacritic (Chinese, Hanyu Pinyin). … … 86 108 87 109 /** 88 110 * @ticket 3782 111 * 112 * @covers ::remove_accents 89 113 */ 90 114 public function test_remove_accents_germanic_umlauts() { 91 115 add_filter( 'locale', array( $this, '_remove_accents_germanic_umlauts_cb' ) ); … … 101 125 102 126 /** 103 127 * @ticket 23907 128 * 129 * @covers ::remove_accents 104 130 */ 105 131 public function test_remove_danish_accents() { 106 132 add_filter( 'locale', array( $this, '_set_locale_to_danish' ) ); … … 116 142 117 143 /** 118 144 * @ticket 37086 145 * 146 * @covers ::remove_accents 119 147 */ 120 148 public function test_remove_catalan_middot() { 121 149 add_filter( 'locale', array( $this, '_set_locale_to_catalan' ) ); … … 133 161 134 162 /** 135 163 * @ticket 38078 164 * 165 * @covers ::remove_accents 136 166 */ 137 167 public function test_transcribe_serbian_crossed_d() { 138 168 add_filter( 'locale', array( $this, '_set_locale_to_serbian' ) ); -
tests/phpunit/tests/formatting/SanitizeFileName.php
4 4 * @group formatting 5 5 */ 6 6 class Tests_Formatting_SanitizeFileName extends WP_UnitTestCase { 7 8 /** 9 * @covers ::sanitize_file_name 10 */ 7 11 function test_munges_extensions() { 8 12 # r17990 9 13 $file_name = sanitize_file_name( 'test.phtml.txt' ); … … 10 14 $this->assertSame( 'test.phtml_.txt', $file_name ); 11 15 } 12 16 17 /** 18 * @covers ::sanitize_file_name 19 */ 13 20 function test_removes_special_chars() { 14 21 $special_chars = array( '?', '[', ']', '/', '\\', '=', '<', '>', ':', ';', ',', "'", '"', '&', '$', '#', '*', '(', ')', '|', '~', '`', '!', '{', '}', '%', '+', '’', '«', '»', '”', '“', chr( 0 ) ); 15 22 $string = 'test'; … … 22 29 23 30 /** 24 31 * @ticket 22363 32 * 33 * @covers ::sanitize_file_name 25 34 */ 26 35 function test_removes_accents() { 27 36 $in = 'àáâãäåæçèéêëìíîïñòóôõöøùúûüýÿ'; … … 33 42 * Test that spaces are correctly replaced with dashes. 34 43 * 35 44 * @ticket 16330 45 * 46 * @covers ::sanitize_file_name 36 47 */ 37 48 function test_replaces_spaces() { 38 49 $urls = array( … … 47 58 } 48 59 } 49 60 61 /** 62 * @covers ::sanitize_file_name 63 */ 50 64 function test_replaces_any_number_of_hyphens_with_one_hyphen() { 51 65 $this->assertSame( 'a-t-t', sanitize_file_name( 'a----t----t' ) ); 52 66 } 53 67 68 /** 69 * @covers ::sanitize_file_name 70 */ 54 71 function test_trims_trailing_hyphens() { 55 72 $this->assertSame( 'a-t-t', sanitize_file_name( 'a----t----t----' ) ); 56 73 } 57 74 75 /** 76 * @covers ::sanitize_file_name 77 */ 58 78 function test_replaces_any_amount_of_whitespace_with_one_hyphen() { 59 79 $this->assertSame( 'a-t', sanitize_file_name( 'a t' ) ); 60 80 $this->assertSame( 'a-t', sanitize_file_name( "a \n\n\nt" ) ); … … 62 82 63 83 /** 64 84 * @ticket 16226 85 * 86 * @covers ::sanitize_file_name 65 87 */ 66 88 function test_replaces_percent_sign() { 67 89 $this->assertSame( 'a22b.jpg', sanitize_file_name( 'a%22b.jpg' ) ); 68 90 } 69 91 92 /** 93 * @covers ::sanitize_file_name 94 */ 70 95 function test_replaces_unnamed_file_extensions() { 71 96 // Test filenames with both supported and unsupported extensions. 72 97 $this->assertSame( 'unnamed-file.exe', sanitize_file_name( '_.exe' ) ); … … 73 98 $this->assertSame( 'unnamed-file.jpg', sanitize_file_name( '_.jpg' ) ); 74 99 } 75 100 101 /** 102 * @covers ::sanitize_file_name 103 */ 76 104 function test_replaces_unnamed_file_extensionless() { 77 105 // Test a filenames that becomes extensionless. 78 106 $this->assertSame( 'no-extension', sanitize_file_name( '_.no-extension' ) ); … … 80 108 81 109 /** 82 110 * @dataProvider data_wp_filenames 111 * 112 * @covers ::sanitize_file_name 83 113 */ 84 114 function test_replaces_invalid_utf8_characters( $input, $expected ) { 85 115 $this->assertSame( $expected, sanitize_file_name( $input ) ); -
tests/phpunit/tests/formatting/SanitizeMimeType.php
7 7 8 8 /** 9 9 * @ticket 17855 10 * 11 * @covers ::sanitize_mime_type 10 12 */ 11 13 function test_sanitize_valid_mime_type() { 12 14 $inputs = array( -
tests/phpunit/tests/formatting/SanitizeOrderby.php
8 8 /** 9 9 * @covers ::sanitize_sql_orderby 10 10 * @dataProvider valid_orderbys 11 * 12 * @covers ::sanitize_sql_orderby 11 13 */ 12 14 function test_valid( $orderby ) { 13 15 $this->assertSame( $orderby, sanitize_sql_orderby( $orderby ) ); … … 35 37 /** 36 38 * @covers ::sanitize_sql_orderby 37 39 * @dataProvider invalid_orderbys 40 * 41 * @covers ::sanitize_sql_orderby 38 42 */ 39 43 function test_invalid( $orderby ) { 40 44 $this->assertFalse( sanitize_sql_orderby( $orderby ) ); -
tests/phpunit/tests/formatting/SanitizeTextField.php
127 127 /** 128 128 * @ticket 32257 129 129 * @dataProvider data_sanitize_text_field 130 * 131 * @covers ::sanitize_text_field 132 * @covers ::sanitize_textarea_field 130 133 */ 131 134 function test_sanitize_text_field( $string, $expected ) { 132 135 if ( is_array( $expected ) ) { -
tests/phpunit/tests/formatting/SanitizeTitle.php
4 4 * @group formatting 5 5 */ 6 6 class Tests_Formatting_SanitizeTitle extends WP_UnitTestCase { 7 8 /** 9 * @covers ::sanitize_title 10 */ 7 11 function test_strips_html() { 8 12 $input = 'Captain <strong>Awesome</strong>'; 9 13 $expected = 'captain-awesome'; … … 10 14 $this->assertSame( $expected, sanitize_title( $input ) ); 11 15 } 12 16 17 /** 18 * @covers ::sanitize_title 19 */ 13 20 function test_titles_sanitized_to_nothing_are_replaced_with_optional_fallback() { 14 21 $input = '<strong></strong>'; 15 22 $fallback = 'Captain Awesome'; -
tests/phpunit/tests/formatting/SanitizeTitleWithDashes.php
4 4 * @group formatting 5 5 */ 6 6 class Tests_Formatting_SanitizeTitleWithDashes extends WP_UnitTestCase { 7 /** 8 * @covers ::sanitize_title_with_dashes 9 */ 7 10 function test_strips_html() { 8 11 $input = 'Captain <strong>Awesome</strong>'; 9 12 $expected = 'captain-awesome'; 10 $this->assertSame( $expected, sanitize_title ( $input ) );13 $this->assertSame( $expected, sanitize_title_with_dashes( $input ) ); 11 14 } 12 15 16 /** 17 * @covers ::sanitize_title_with_dashes 18 */ 13 19 function test_strips_unencoded_percent_signs() { 14 20 $this->assertSame( 'fran%c3%a7ois', sanitize_title_with_dashes( 'fran%c3%a7%ois' ) ); 15 21 } 16 22 23 /** 24 * @covers ::sanitize_title_with_dashes 25 */ 17 26 function test_makes_title_lowercase() { 18 27 $this->assertSame( 'abc', sanitize_title_with_dashes( 'ABC' ) ); 19 28 } 20 29 30 /** 31 * @covers ::sanitize_title_with_dashes 32 */ 21 33 function test_replaces_any_amount_of_whitespace_with_one_hyphen() { 22 34 $this->assertSame( 'a-t', sanitize_title_with_dashes( 'a t' ) ); 23 35 $this->assertSame( 'a-t', sanitize_title_with_dashes( "a \n\n\nt" ) ); 24 36 } 25 37 38 /** 39 * @covers ::sanitize_title_with_dashes 40 */ 26 41 function test_replaces_any_number_of_hyphens_with_one_hyphen() { 27 42 $this->assertSame( 'a-t-t', sanitize_title_with_dashes( 'a----t----t' ) ); 28 43 } 29 44 45 /** 46 * @covers ::sanitize_title_with_dashes 47 */ 30 48 function test_trims_trailing_hyphens() { 31 49 $this->assertSame( 'a-t-t', sanitize_title_with_dashes( 'a----t----t----' ) ); 32 50 } 33 51 52 /** 53 * @covers ::sanitize_title_with_dashes 54 */ 34 55 function test_handles_non_entity_ampersands() { 35 56 $this->assertSame( 'penn-teller-bull', sanitize_title_with_dashes( 'penn & teller bull' ) ); 36 57 } 37 58 59 /** 60 * @covers ::sanitize_title_with_dashes 61 */ 38 62 public function test_strips_nbsp_ndash_and_amp() { 39 63 $this->assertSame( 'no-entities-here', sanitize_title_with_dashes( 'No Entities – Here &' ) ); 40 64 } 41 65 66 /** 67 * @covers ::sanitize_title_with_dashes 68 */ 42 69 public function test_strips_encoded_ampersand() { 43 70 $this->assertSame( 'one-two', sanitize_title_with_dashes( 'One & Two', '', 'save' ) ); 44 71 } 45 72 73 /** 74 * @covers ::sanitize_title_with_dashes 75 */ 46 76 public function test_strips_url_encoded_ampersand() { 47 77 $this->assertSame( 'one-two', sanitize_title_with_dashes( 'One { Two;', '', 'save' ) ); 48 78 } 49 79 80 /** 81 * @covers ::sanitize_title_with_dashes 82 */ 50 83 public function test_strips_trademark_symbol() { 51 84 $this->assertSame( 'one-two', sanitize_title_with_dashes( 'One Two™;', '', 'save' ) ); 52 85 } 53 86 87 /** 88 * @covers ::sanitize_title_with_dashes 89 */ 54 90 public function test_strips_unencoded_ampersand_followed_by_encoded_ampersand() { 55 91 $this->assertSame( 'one-two', sanitize_title_with_dashes( 'One && Two;', '', 'save' ) ); 56 92 } 57 93 94 /** 95 * @covers ::sanitize_title_with_dashes 96 */ 58 97 public function test_strips_unencoded_ampersand_when_not_surrounded_by_spaces() { 59 98 $this->assertSame( 'onetwo', sanitize_title_with_dashes( 'One&Two', '', 'save' ) ); 60 99 } … … 65 104 66 105 /** 67 106 * @ticket 31790 107 * 108 * @covers ::sanitize_title_with_dashes 68 109 */ 69 110 function test_replaces_nbsp_entities() { 70 111 $this->assertSame( 'dont-break-the-space', sanitize_title_with_dashes( "don't break the space", '', 'save' ) ); 71 112 } 72 113 114 /** 115 * @covers ::sanitize_title_with_dashes 116 */ 73 117 function test_replaces_ndash_mdash() { 74 118 $this->assertSame( 'do-the-dash', sanitize_title_with_dashes( 'Do – the Dash', '', 'save' ) ); 75 119 $this->assertSame( 'do-the-dash', sanitize_title_with_dashes( 'Do the — Dash', '', 'save' ) ); … … 77 121 78 122 /** 79 123 * @ticket 31790 124 * 125 * @covers ::sanitize_title_with_dashes 80 126 */ 81 127 function test_replaces_ndash_mdash_entities() { 82 128 $this->assertSame( 'do-the-dash', sanitize_title_with_dashes( 'Do – the – Dash', '', 'save' ) ); … … 83 129 $this->assertSame( 'do-the-dash', sanitize_title_with_dashes( 'Do — the — Dash', '', 'save' ) ); 84 130 } 85 131 132 /** 133 * @covers ::sanitize_title_with_dashes 134 */ 86 135 function test_replaces_iexcel_iquest() { 87 136 $this->assertSame( 'just-a-slug', sanitize_title_with_dashes( 'Just ¡a Slug', '', 'save' ) ); 88 137 $this->assertSame( 'just-a-slug', sanitize_title_with_dashes( 'Just a Slug¿', '', 'save' ) ); 89 138 } 90 139 140 /** 141 * @covers ::sanitize_title_with_dashes 142 */ 91 143 function test_replaces_angle_quotes() { 92 144 $this->assertSame( 'just-a-slug', sanitize_title_with_dashes( '‹Just a Slug›', '', 'save' ) ); 93 145 $this->assertSame( 'just-a-slug', sanitize_title_with_dashes( '«Just a Slug»', '', 'save' ) ); 94 146 } 95 147 148 /** 149 * @covers ::sanitize_title_with_dashes 150 */ 96 151 function test_replaces_curly_quotes() { 97 152 $this->assertSame( 'hey-its-curly-joe', sanitize_title_with_dashes( 'Hey its “Curly Joe”', '', 'save' ) ); 98 153 $this->assertSame( 'hey-its-curly-joe', sanitize_title_with_dashes( 'Hey its ‘Curly Joe’', '', 'save' ) ); … … 103 158 104 159 /** 105 160 * @ticket 49791 161 * 162 * @covers ::sanitize_title_with_dashes 106 163 */ 107 164 function test_replaces_bullet() { 108 165 $this->assertSame( 'fancy-title-amazing', sanitize_title_with_dashes( 'Fancy Title • Amazing', '', 'save' ) ); 109 166 } 110 167 /** 168 * @covers ::sanitize_title_with_dashes 169 */ 111 170 function test_replaces_copy_reg_deg_trade() { 112 171 $this->assertSame( 'just-a-slug', sanitize_title_with_dashes( 'Just © a Slug', '', 'save' ) ); 113 172 $this->assertSame( 'just-a-slug', sanitize_title_with_dashes( '® Just a Slug', '', 'save' ) ); … … 117 176 118 177 /** 119 178 * @ticket 10792 179 * 180 * @covers ::sanitize_title_with_dashes 120 181 */ 121 182 function test_replaces_forward_slash() { 122 183 $this->assertSame( 'songs-by-lennon-mccartney', sanitize_title_with_dashes( 'songs by Lennon/McCartney', '', 'save' ) ); … … 128 189 129 190 /** 130 191 * @ticket 19820 192 * 193 * @covers ::sanitize_title_with_dashes 131 194 */ 132 195 function test_replaces_multiply_sign() { 133 196 $this->assertSame( '6x7-is-42', sanitize_title_with_dashes( '6×7 is 42', '', 'save' ) ); … … 135 198 136 199 /** 137 200 * @ticket 20772 201 * 202 * @covers ::sanitize_title_with_dashes 138 203 */ 139 204 function test_replaces_standalone_diacritic() { 140 205 $this->assertSame( 'aaaa', sanitize_title_with_dashes( 'āáǎà', '', 'save' ) ); … … 142 207 143 208 /** 144 209 * @ticket 22395 210 * 211 * @covers ::sanitize_title_with_dashes 145 212 */ 146 213 function test_replaces_acute_accents() { 147 214 $this->assertSame( 'aaaa', sanitize_title_with_dashes( 'ááa´aˊ', '', 'save' ) ); -
tests/phpunit/tests/formatting/SanitizeTrackbackUrls.php
7 7 /** 8 8 * @ticket 21624 9 9 * @dataProvider breaks 10 * 11 * @covers ::sanitize_trackback_urls 10 12 */ 11 13 function test_sanitize_trackback_urls_with_multiple_urls( $break ) { 12 14 $this->assertSame( "http://example.com\nhttp://example.org", sanitize_trackback_urls( "http://example.com{$break}http://example.org" ) ); -
tests/phpunit/tests/formatting/SanitizeUser.php
4 4 * @group formatting 5 5 */ 6 6 class Tests_Formatting_SanitizeUser extends WP_UnitTestCase { 7 8 /** 9 * @covers ::sanitize_user 10 */ 7 11 function test_strips_html() { 8 12 $input = 'Captain <strong>Awesome</strong>'; 9 13 $expected = is_multisite() ? 'captain awesome' : 'Captain Awesome'; … … 10 14 $this->assertSame( $expected, sanitize_user( $input ) ); 11 15 } 12 16 17 /** 18 * @covers ::sanitize_user 19 */ 13 20 public function test_strips_encoded_ampersand() { 14 21 $expected = 'ATT'; 15 22 … … 21 28 $this->assertSame( $expected, sanitize_user( 'AT&T' ) ); 22 29 } 23 30 31 /** 32 * @covers ::sanitize_user 33 */ 24 34 public function test_strips_encoded_ampersand_when_followed_by_semicolon() { 25 35 $expected = 'ATT Test;'; 26 36 … … 32 42 $this->assertSame( $expected, sanitize_user( 'AT&T Test;' ) ); 33 43 } 34 44 45 /** 46 * @covers ::sanitize_user 47 */ 35 48 function test_strips_percent_encoded_octets() { 36 49 $expected = is_multisite() ? 'franois' : 'Franois'; 37 50 $this->assertSame( $expected, sanitize_user( 'Fran%c3%a7ois' ) ); 38 51 } 52 53 /** 54 * @covers ::sanitize_user 55 */ 39 56 function test_optional_strict_mode_reduces_to_safe_ascii_subset() { 40 57 $this->assertSame( 'abc', sanitize_user( '()~ab~ˆcˆ!', true ) ); 41 58 } -
tests/phpunit/tests/formatting/SeemsUtf8.php
9 9 * `seems_utf8` returns true for utf-8 strings, false otherwise. 10 10 * 11 11 * @dataProvider utf8_strings 12 * 13 * @covers ::seems_utf8 12 14 */ 13 15 function test_returns_true_for_utf8_strings( $utf8_string ) { 14 16 // From http://www.i18nguy.com/unicode-example.html … … 26 28 27 29 /** 28 30 * @dataProvider big5_strings 31 * 32 * @covers ::seems_utf8 29 33 */ 30 34 function test_returns_false_for_non_utf8_strings( $big5_string ) { 31 35 $this->assertFalse( seems_utf8( $big5_string ) ); -
tests/phpunit/tests/formatting/Slashit.php
4 4 * @group formatting 5 5 */ 6 6 class Tests_Formatting_Slashit extends WP_UnitTestCase { 7 8 /** 9 * @covers ::backslashit 10 */ 7 11 function test_backslashes_middle_numbers() { 8 12 $this->assertSame( "\\a-!9\\a943\\b\\c", backslashit( 'a-!9a943bc' ) ); 9 13 } 10 14 15 /** 16 * @covers ::backslashit 17 */ 11 18 function test_backslashes_alphas() { 12 19 $this->assertSame( "\\a943\\b\\c", backslashit( 'a943bc' ) ); 13 20 } 14 21 22 /** 23 * @covers ::backslashit 24 */ 15 25 function test_double_backslashes_leading_numbers() { 16 26 $this->assertSame( '\\\\95', backslashit( '95' ) ); 17 27 } 18 28 29 /** 30 * @covers ::untrailingslashit 31 */ 19 32 function test_removes_trailing_slashes() { 20 33 $this->assertSame( 'a', untrailingslashit( 'a/' ) ); 21 34 $this->assertSame( 'a', untrailingslashit( 'a////' ) ); … … 23 36 24 37 /** 25 38 * @ticket 22267 39 * 40 * @covers ::untrailingslashit 26 41 */ 27 42 function test_removes_trailing_backslashes() { 28 43 $this->assertSame( 'a', untrailingslashit( 'a\\' ) ); … … 31 46 32 47 /** 33 48 * @ticket 22267 49 * 50 * @covers ::untrailingslashit 34 51 */ 35 52 function test_removes_trailing_mixed_slashes() { 36 53 $this->assertSame( 'a', untrailingslashit( 'a/\\' ) ); … … 37 54 $this->assertSame( 'a', untrailingslashit( 'a\\/\\///\\\\//' ) ); 38 55 } 39 56 57 /** 58 * @covers ::trailingslashit 59 */ 40 60 function test_adds_trailing_slash() { 41 61 $this->assertSame( 'a/', trailingslashit( 'a' ) ); 42 62 } 43 63 64 /** 65 * @covers ::trailingslashit 66 */ 44 67 function test_does_not_add_trailing_slash_if_one_exists() { 45 68 $this->assertSame( 'a/', trailingslashit( 'a/' ) ); 46 69 } … … 47 70 48 71 /** 49 72 * @ticket 22267 73 * 74 * @covers ::trailingslashit 50 75 */ 51 76 function test_converts_trailing_backslash_to_slash_if_one_exists() { 52 77 $this->assertSame( 'a/', trailingslashit( 'a\\' ) ); -
tests/phpunit/tests/formatting/Smilies.php
47 47 * 48 48 * Basic Validation Test to confirm that smilies are converted to image 49 49 * when use_smilies = 1 and not when use_smilies = 0 50 * 51 * @covers ::convert_smilies 50 52 */ 51 53 function test_convert_standard_smilies( $in_txt, $converted_txt ) { 52 54 // Standard smilies, use_smilies: ON. … … 90 92 * @dataProvider get_custom_smilies_input_output 91 93 * 92 94 * Validate Custom Smilies are converted to images when use_smilies = 1 95 * 96 * @covers ::convert_smilies 93 97 */ 94 98 function test_convert_custom_smilies( $in_txt, $converted_txt ) { 95 99 global $wpsmiliestrans; … … 142 146 * 143 147 * @ticket 16448 144 148 * @dataProvider get_smilies_ignore_tags 149 * 150 * @covers ::convert_smilies 145 151 */ 146 152 public function test_ignore_smilies_in_tags( $element ) { 147 153 $includes_path = includes_url( 'images/smilies/' ); … … 199 205 * 200 206 * @ticket 20124 201 207 * @dataProvider get_smilies_combinations 208 * 209 * @covers ::convert_smilies 202 210 */ 203 211 public function test_smilies_combinations( $in_txt, $converted_txt ) { 204 212 // Custom smilies, use_smilies: ON. … … 241 249 * 242 250 * @ticket 25303 243 251 * @dataProvider get_single_smilies_input_output 252 * 253 * @covers ::convert_smilies 244 254 */ 245 255 public function test_single_smilies_in_wpsmiliestrans( $in_txt, $converted_txt ) { 246 256 global $wpsmiliestrans; … … 298 308 * 299 309 * @ticket 22692 300 310 * @dataProvider get_spaces_around_smilies 311 * 312 * @covers ::convert_smilies 301 313 */ 302 314 function test_spaces_around_smilies( $in_txt, $converted_txt ) { 303 315 // Standard smilies, use_smilies: ON. … … 315 327 * Test to ensure smilies can be removed with a filter 316 328 * 317 329 * @ticket 35905 330 * 331 * @covers ::convert_smilies 318 332 */ 319 333 public function test_smilies_filter_removes_smilies() { 320 334 add_filter( 'smilies', array( $this, '_filter_remove_smilies' ) ); … … 330 344 * Test to ensure smilies can be added with a filter 331 345 * 332 346 * @ticket 35905 347 * 348 * @covers ::convert_smilies 333 349 */ 334 350 public function test_smilies_filter_adds_smilies() { 335 351 add_filter( 'smilies', array( $this, '_filter_add_smilies' ) ); -
tests/phpunit/tests/formatting/StripSlashesDeep.php
7 7 class Tests_Formatting_StripSlashesDeep extends WP_UnitTestCase { 8 8 /** 9 9 * @ticket 18026 10 * 11 * @covers ::stripslashes_deep 10 12 */ 11 13 function test_preserves_original_datatype() { 12 14 … … 31 33 $this->assertSame( $obj, stripslashes_deep( $obj ) ); 32 34 } 33 35 36 /** 37 * @covers ::stripslashes_deep 38 */ 34 39 function test_strips_slashes() { 35 40 $old = "I can\'t see, isn\'t that it?"; 36 41 $new = "I can't see, isn't that it?"; … … 46 51 $this->assertEquals( $obj_new, stripslashes_deep( $obj_old ) ); 47 52 } 48 53 54 /** 55 * @covers ::stripslashes_deep 56 */ 49 57 function test_permits_escaped_slash() { 50 58 $txt = "I can't see, isn\'t that it?"; 51 59 $this->assertSame( $txt, stripslashes_deep( "I can\'t see, isn\\\'t that it?" ) ); -
tests/phpunit/tests/formatting/UrlencodeDeep.php
26 26 * 27 27 * @param string $actual 28 28 * @param string $expected 29 * 30 * @covers ::urlencode_deep 29 31 */ 30 32 public function test_urlencode_deep_should_encode_individual_value( $actual, $expected ) { 31 33 $this->assertSame( $expected, urlencode_deep( $actual ) ); … … 33 35 34 36 /** 35 37 * Test the whole array as input 38 * 39 * @covers ::urlencode_deep 36 40 */ 37 41 public function test_urlencode_deep_should_encode_all_values_in_array() { 38 42 $data = $this->data_test_values(); -
tests/phpunit/tests/formatting/URLShorten.php
4 4 * @group formatting 5 5 */ 6 6 class Tests_Formatting_URLShorten extends WP_UnitTestCase { 7 8 /** 9 * @covers ::url_shorten 10 */ 7 11 function test_shorten_url() { 8 12 $tests = array( 9 13 'wordpress\.org/about/philosophy' => 'wordpress\.org/about/philosophy', // No longer strips slashes. -
tests/phpunit/tests/formatting/Utf8UriEncode.php
10 10 * are dealt with elsewhere. 11 11 * 12 12 * @dataProvider data 13 * 14 * @covers ::utf8_uri_encode 13 15 */ 14 16 function test_percent_encodes_non_reserved_characters( $utf8, $urlencoded ) { 15 17 $this->assertSame( $urlencoded, utf8_uri_encode( $utf8 ) ); … … 17 19 18 20 /** 19 21 * @dataProvider data 22 * 23 * @covers ::utf8_uri_encode 20 24 */ 21 25 function test_output_is_not_longer_than_optional_length_argument( $utf8, $unused_for_this_test ) { 22 26 $max_length = 30; -
tests/phpunit/tests/formatting/WPBasename.php
5 5 */ 6 6 class Tests_Formatting_WP_Basename extends WP_UnitTestCase { 7 7 8 /** 9 * @covers ::wp_basename 10 */ 8 11 function test_wp_basename_unix() { 9 12 $this->assertSame( 10 13 'file', … … 12 15 ); 13 16 } 14 17 18 /** 19 * @covers ::wp_basename 20 */ 15 21 function test_wp_basename_unix_utf8_support() { 16 22 $this->assertSame( 17 23 'žluťoučký kůň.txt', … … 21 27 22 28 /** 23 29 * @ticket 22138 30 * 31 * @covers ::wp_basename 24 32 */ 25 33 function test_wp_basename_windows() { 26 34 $this->assertSame( … … 31 39 32 40 /** 33 41 * @ticket 22138 42 * 43 * @covers ::wp_basename 34 44 */ 35 45 function test_wp_basename_windows_utf8_support() { 36 46 $this->assertSame( -
tests/phpunit/tests/formatting/WpHtmlEditPre.php
13 13 /* 14 14 * Only fails in PHP 5.4 onwards 15 15 * @ticket 23688 16 * 17 * @covers ::wp_htmledit_pre 16 18 */ 17 19 function test_wp_htmledit_pre_charset_iso_8859_1() { 18 20 add_filter( 'pre_option_blog_charset', array( $this, '_charset_iso_8859_1' ) ); … … 27 29 28 30 /* 29 31 * @ticket 23688 32 * 33 * @covers ::wp_htmledit_pre 30 34 */ 31 35 function test_wp_htmledit_pre_charset_utf_8() { 32 36 add_filter( 'pre_option_blog_charset', array( $this, '_charset_utf_8' ) ); -
tests/phpunit/tests/formatting/WpHtmlSplit.php
9 9 * Basic functionality goes here. 10 10 * 11 11 * @dataProvider data_basic_features 12 * 13 * @covers ::wp_html_split 12 14 */ 13 15 function test_basic_features( $input, $output ) { 14 16 return $this->assertSame( $output, wp_html_split( $input ) ); … … 39 41 * Automated performance testing of the main regex. 40 42 * 41 43 * @dataProvider data_whole_posts 44 * 45 * @covers ::preg_split 42 46 */ 43 47 function test_pcre_performance( $input ) { 44 48 $regex = get_html_split_regex(); -
tests/phpunit/tests/formatting/WPMakeLinkRelative.php
5 5 */ 6 6 class Tests_Formatting_WPMakeLinkRelative extends WP_UnitTestCase { 7 7 8 /** 9 * @covers ::wp_make_link_relative 10 */ 8 11 public function test_wp_make_link_relative_with_http_scheme() { 9 12 $link = 'http://example.com/this-is-a-test-http-url/'; 10 13 $relative_link = wp_make_link_relative( $link ); … … 11 14 $this->assertSame( '/this-is-a-test-http-url/', $relative_link ); 12 15 } 13 16 17 18 /** 19 * @covers ::wp_make_link_relative 20 */ 14 21 public function test_wp_make_link_relative_with_https_scheme() { 15 22 $link = 'https://example.com/this-is-a-test-https-url/'; 16 23 $relative_link = wp_make_link_relative( $link ); … … 19 26 20 27 /** 21 28 * @ticket 30373 29 * 30 * @covers ::wp_make_link_relative 22 31 */ 23 32 public function test_wp_make_link_relative_with_no_scheme() { 24 33 $link = '//example.com/this-is-a-test-schemeless-url/'; … … 28 37 29 38 /** 30 39 * @ticket 30373 40 * 41 * @covers ::wp_make_link_relative 31 42 */ 32 43 public function test_wp_make_link_relative_should_retain_URL_param_that_is_also_a_URL() { 33 44 $link = 'https://example.com/this-is-a-test/?redirect=https://example.org/a-different-test-post/'; … … 37 48 38 49 /** 39 50 * @ticket 26819 51 * 52 * @covers ::wp_make_link_relative 40 53 */ 41 54 function test_wp_make_link_relative_with_no_path() { 42 55 $link = 'http://example.com'; -
tests/phpunit/tests/formatting/WPRelNoFollow.php
7 7 8 8 /** 9 9 * @ticket 9959 10 * 11 * @covers ::wp_rel_nofollow 10 12 */ 11 13 public function test_add_no_follow() { 12 14 $content = '<p>This is some cool <a href="/">Code</a></p>'; … … 16 18 17 19 /** 18 20 * @ticket 9959 21 * 22 * @covers ::wp_rel_nofollow 19 23 */ 20 24 public function test_convert_no_follow() { 21 25 $content = '<p>This is some cool <a href="/" rel="weird">Code</a></p>'; … … 26 30 /** 27 31 * @ticket 11360 28 32 * @dataProvider data_wp_rel_nofollow 33 * 34 * @covers ::wp_rel_nofollow 29 35 */ 30 36 public function test_wp_rel_nofollow( $input, $output ) { 31 37 return $this->assertSame( wp_slash( $output ), wp_rel_nofollow( $input ) ); -
tests/phpunit/tests/formatting/WPRelUgc.php
7 7 8 8 /** 9 9 * @ticket 48022 10 * 11 * @covers ::wp_rel_ugc 10 12 */ 11 13 public function test_add_ugc() { 12 14 $content = '<p>This is some cool <a href="/">Code</a></p>'; … … 16 18 17 19 /** 18 20 * @ticket 48022 21 * 22 * @covers ::wp_rel_ugc 19 23 */ 20 24 public function test_convert_ugc() { 21 25 $content = '<p>This is some cool <a href="/" rel="weird">Code</a></p>'; … … 26 30 /** 27 31 * @ticket 48022 28 32 * @dataProvider data_wp_rel_ugc 33 * 34 * @covers ::wp_rel_ugc 29 35 */ 30 36 public function test_wp_rel_ugc( $input, $output ) { 31 37 return $this->assertSame( wp_slash( $output ), wp_rel_ugc( $input ) ); … … 75 81 ); 76 82 } 77 83 84 /** 85 * @covers ::wp_rel_ugc 86 */ 78 87 public function test_append_ugc_with_valueless_attribute() { 79 88 $content = '<p>This is some cool <a href="demo.com" download rel="hola">Code</a></p>'; 80 89 $expected = '<p>This is some cool <a href=\"demo.com\" download rel=\"hola nofollow ugc\">Code</a></p>'; -
tests/phpunit/tests/formatting/WpReplaceInHtmlTags.php
8 8 * Check for expected behavior of new function wp_replace_in_html_tags(). 9 9 * 10 10 * @dataProvider data_wp_replace_in_html_tags 11 * 12 * @covers ::wp_replace_in_html_tags 11 13 */ 12 14 function test_wp_replace_in_html_tags( $input, $output ) { 13 15 return $this->assertSame( $output, wp_replace_in_html_tags( $input, array( "\n" => ' ' ) ) ); -
tests/phpunit/tests/formatting/WpRichEditPre.php
13 13 /* 14 14 * Only fails in PHP 5.4 onwards 15 15 * @ticket 23688 16 * 17 * @covers ::wp_richedit_pre 16 18 */ 17 19 function test_wp_richedit_pre_charset_iso_8859_1() { 18 20 add_filter( 'pre_option_blog_charset', array( $this, '_charset_iso_8859_1' ) ); … … 27 29 28 30 /* 29 31 * @ticket 23688 32 * 33 * @covers ::wp_richedit_pre 30 34 */ 31 35 function test_wp_richedit_pre_charset_utf_8() { 32 36 add_filter( 'pre_option_blog_charset', array( $this, '_charset_utf_8' ) ); -
tests/phpunit/tests/formatting/WPSlash.php
12 12 * 13 13 * @param string $value 14 14 * @param string $expected 15 * 16 * @covers ::wp_slash 15 17 */ 16 18 public function test_wp_slash( $value, $expected ) { 17 19 $this->assertSame( $expected, wp_slash( $value ) ); … … 53 55 54 56 /** 55 57 * @ticket 24106 58 * 59 * @covers ::wp_slash 56 60 */ 57 61 function test_adds_slashes() { 58 62 $old = "I can't see, isn't that it?"; … … 65 69 66 70 /** 67 71 * @ticket 24106 72 * 73 * @covers ::wp_slash 68 74 */ 69 75 function test_preserves_original_datatype() { 70 76 … … 91 97 92 98 /** 93 99 * @ticket 24106 100 * 101 * @covers ::wp_slash 94 102 */ 95 103 function test_add_even_more_slashes() { 96 104 $old = 'single\\slash double\\\\slash triple\\\\\\slash'; -
tests/phpunit/tests/formatting/WPSpecialchars.php
4 4 * @group formatting 5 5 */ 6 6 class Tests_Formatting_WPSpecialchars extends WP_UnitTestCase { 7 8 /** 9 * @covers ::_wp_specialchars 10 */ 7 11 function test_wp_specialchars_basics() { 8 12 $html = '&<hello world>'; 9 13 $this->assertSame( $html, _wp_specialchars( $html ) ); … … 12 16 $this->assertSame( $double, _wp_specialchars( $html, ENT_NOQUOTES, false, true ) ); 13 17 } 14 18 19 /** 20 * @covers ::_wp_specialchars 21 */ 15 22 function test_allowed_entity_names() { 16 23 global $allowedentitynames; 17 24 … … 26 33 } 27 34 } 28 35 36 /** 37 * @covers ::_wp_specialchars 38 */ 29 39 function test_not_allowed_entity_names() { 30 40 $ents = array( 'iacut', 'aposs', 'pos', 'apo', 'apo?', 'apo.*', '.*apo.*', 'apos ', ' apos', ' apos ' ); 31 41 … … 36 46 } 37 47 } 38 48 49 /** 50 * @covers ::_wp_specialchars 51 */ 39 52 function test_optionally_escapes_quotes() { 40 53 $source = "\"'hello!'\""; 41 54 $this->assertSame( '"'hello!'"', _wp_specialchars( $source, 'single' ) ); … … 49 62 * 50 63 * @ticket 17780 51 64 * @dataProvider data_double_encoding 65 * 66 * @covers ::_wp_specialchars 52 67 */ 53 68 function test_double_encoding( $input, $output ) { 54 69 return $this->assertSame( $output, _wp_specialchars( $input, ENT_NOQUOTES, false, true ) ); … … 76 91 * 77 92 * @ticket 17780 78 93 * @dataProvider data_no_double_encoding 94 * 95 * @covers ::_wp_specialchars 79 96 */ 80 97 function test_no_double_encoding( $input, $output ) { 81 98 return $this->assertSame( $output, _wp_specialchars( $input, ENT_NOQUOTES, false, false ) ); -
tests/phpunit/tests/formatting/WPStripAllTags.php
6 6 */ 7 7 class Tests_Formatting_WPStripAllTags extends WP_UnitTestCase { 8 8 9 /** 10 * @covers ::wp_strip_all_tags 11 */ 9 12 function test_wp_strip_all_tags() { 10 13 11 14 $text = 'lorem<br />ipsum'; -
tests/phpunit/tests/formatting/WPTargetedLinkRel.php
6 6 */ 7 7 class Tests_Targeted_Link_Rel extends WP_UnitTestCase { 8 8 9 /** 10 * @covers ::wp_targeted_link_rel 11 */ 9 12 public function test_add_to_links_with_target_blank() { 10 13 $content = '<p>Links: <a href="/" target="_blank">No rel</a></p>'; 11 14 $expected = '<p>Links: <a href="/" target="_blank" rel="noopener">No rel</a></p>'; … … 12 15 $this->assertSame( $expected, wp_targeted_link_rel( $content ) ); 13 16 } 14 17 18 /** 19 * @covers ::wp_targeted_link_rel 20 */ 15 21 public function test_add_to_links_with_target_foo() { 16 22 $content = '<p>Links: <a href="/" target="foo">No rel</a></p>'; 17 23 $expected = '<p>Links: <a href="/" target="foo" rel="noopener">No rel</a></p>'; … … 18 24 $this->assertSame( $expected, wp_targeted_link_rel( $content ) ); 19 25 } 20 26 27 /** 28 * @covers ::wp_targeted_link_rel 29 */ 21 30 public function test_target_as_first_attribute() { 22 31 $content = '<p>Links: <a target="_blank" href="#">No rel</a></p>'; 23 32 $expected = '<p>Links: <a target="_blank" href="#" rel="noopener">No rel</a></p>'; … … 24 33 $this->assertSame( $expected, wp_targeted_link_rel( $content ) ); 25 34 } 26 35 36 /** 37 * @covers ::wp_targeted_link_rel 38 */ 27 39 public function test_add_to_existing_rel() { 28 40 $content = '<p>Links: <a href="/" rel="existing values" target="_blank">Existing rel</a></p>'; 29 41 $expected = '<p>Links: <a href="/" rel="existing values noopener" target="_blank">Existing rel</a></p>'; … … 30 42 $this->assertSame( $expected, wp_targeted_link_rel( $content ) ); 31 43 } 32 44 45 /** 46 * @covers ::wp_targeted_link_rel 47 */ 33 48 public function test_no_duplicate_values_added() { 34 49 $content = '<p>Links: <a href="/" rel="existing noopener values" target="_blank">Existing rel</a></p>'; 35 50 $expected = '<p>Links: <a href="/" rel="existing noopener values" target="_blank">Existing rel</a></p>'; … … 36 51 $this->assertSame( $expected, wp_targeted_link_rel( $content ) ); 37 52 } 38 53 54 /** 55 * @covers ::wp_targeted_link_rel 56 */ 39 57 public function test_rel_with_single_quote_delimiter() { 40 58 $content = '<p>Links: <a href="/" rel=\'existing values\' target="_blank">Existing rel</a></p>'; 41 59 $expected = '<p>Links: <a href="/" rel="existing values noopener" target="_blank">Existing rel</a></p>'; … … 42 60 $this->assertSame( $expected, wp_targeted_link_rel( $content ) ); 43 61 } 44 62 63 /** 64 * @covers ::wp_targeted_link_rel 65 */ 45 66 public function test_rel_with_no_delimiter() { 46 67 $content = '<p>Links: <a href="/" rel=existing target="_blank">Existing rel</a></p>'; 47 68 $expected = '<p>Links: <a href="/" rel="existing noopener" target="_blank">Existing rel</a></p>'; … … 48 69 $this->assertSame( $expected, wp_targeted_link_rel( $content ) ); 49 70 } 50 71 72 /** 73 * @covers ::wp_targeted_link_rel 74 */ 51 75 public function test_rel_value_spaced_and_no_delimiter() { 52 76 $content = '<p>Links: <a href="/" rel = existing target="_blank">Existing rel</a></p>'; 53 77 $expected = '<p>Links: <a href="/" rel="existing noopener" target="_blank">Existing rel</a></p>'; … … 54 78 $this->assertSame( $expected, wp_targeted_link_rel( $content ) ); 55 79 } 56 80 81 /** 82 * @covers ::wp_targeted_link_rel 83 */ 57 84 public function test_escaped_quotes() { 58 85 $content = '<p>Links: <a href=\"/\" rel=\"existing values\" target=\"_blank\">Existing rel</a></p>'; 59 86 $expected = '<p>Links: <a href=\"/\" rel=\"existing values noopener\" target=\"_blank\">Existing rel</a></p>'; … … 60 87 $this->assertSame( $expected, wp_targeted_link_rel( $content ) ); 61 88 } 62 89 90 /** 91 * @covers ::wp_targeted_link_rel 92 */ 63 93 public function test_ignore_links_with_no_target() { 64 94 $content = '<p>Links: <a href="/" target="_blank">Change me</a> <a href="/">Do not change me</a></p>'; 65 95 $expected = '<p>Links: <a href="/" target="_blank" rel="noopener">Change me</a> <a href="/">Do not change me</a></p>'; … … 70 100 * Ensure empty rel attributes are not added. 71 101 * 72 102 * @ticket 45352 103 * 104 * @covers ::wp_targeted_link_rel 73 105 */ 74 106 public function test_ignore_if_wp_targeted_link_rel_nulled() { 75 107 add_filter( 'wp_targeted_link_rel', '__return_empty_string' ); … … 82 114 * Ensure default content filters are added. 83 115 * 84 116 * @ticket 45292 117 * 118 * @covers ::wp_targeted_link_rel 85 119 */ 86 120 public function test_wp_targeted_link_rel_filters_run() { 87 121 $content = '<p>Links: <a href="/" target="_blank">No rel</a></p>'; … … 100 134 * Ensure JSON format is preserved when relation attribute (rel) is missing. 101 135 * 102 136 * @ticket 46316 137 * 138 * @covers ::wp_targeted_link_rel 103 139 */ 104 140 public function test_wp_targeted_link_rel_should_preserve_json() { 105 141 $content = '<p>Links: <a href=\"\/\" target=\"_blank\">No rel<\/a><\/p>'; … … 111 147 * Ensure the content of style and script tags are not processed 112 148 * 113 149 * @ticket 47244 150 * 151 * @covers ::wp_targeted_link_rel 114 152 */ 115 153 public function test_wp_targeted_link_rel_skips_style_and_scripts() { 116 154 $content = '<style><a href="/" target=a></style><p>Links: <script>console.log("<a href=\'/\' target=a>hi</a>");</script><script>alert(1);</script>here <a href="/" target=_blank>aq</a></p><script>console.log("<a href=\'last\' target=\'_blank\'")</script>'; … … 122 160 * Ensure entirely serialized content is ignored. 123 161 * 124 162 * @ticket 46402 163 * 164 * @covers ::wp_targeted_link_rel 125 165 */ 126 166 public function test_ignore_entirely_serialized_content() { 127 167 $content = 'a:1:{s:4:"html";s:52:"<p>Links: <a href="/" target="_blank">No Rel</a></p>";}'; … … 129 169 $this->assertSame( $expected, wp_targeted_link_rel( $content ) ); 130 170 } 131 171 172 /** 173 * @covers ::wp_targeted_link_rel 174 */ 132 175 public function test_wp_targeted_link_rel_tab_separated_values_are_split() { 133 176 $content = "<p>Links: <a href=\"/\" target=\"_blank\" rel=\"ugc\t\tnoopener\t\">No rel</a></p>"; 134 177 $expected = '<p>Links: <a href="/" target="_blank" rel="ugc noopener">No rel</a></p>'; -
tests/phpunit/tests/formatting/WPTexturize.php
4 4 * @group formatting 5 5 */ 6 6 class Tests_Formatting_WPTexturize extends WP_UnitTestCase { 7 8 /** 9 * @covers ::wptexturize 10 */ 7 11 function test_dashes() { 8 12 $this->assertSame( 'Hey — boo?', wptexturize( 'Hey -- boo?' ) ); 9 13 $this->assertSame( '<a href="http://xx--xx">Hey — boo?</a>', wptexturize( '<a href="http://xx--xx">Hey -- boo?</a>' ) ); 10 14 } 11 15 16 /** 17 * @covers ::wptexturize 18 */ 12 19 function test_disable() { 13 20 $this->assertSame( '<pre>---&</pre>', wptexturize( '<pre>---&</pre>' ) ); 14 21 $this->assertSame( '<pre><code></code>--&</pre>', wptexturize( '<pre><code></code>--&</pre>' ) ); … … 34 41 35 42 /** 36 43 * @ticket 1418 44 * 45 * @covers ::wptexturize 37 46 */ 38 47 function test_bracketed_quotes_1418() { 39 48 $this->assertSame( '(“test”)', wptexturize( '("test")' ) ); … … 43 52 44 53 /** 45 54 * @ticket 3810 55 * 56 * @covers ::wptexturize 46 57 */ 47 58 function test_bracketed_quotes_3810() { 48 59 $this->assertSame( 'A dog (“Hubertus”) was sent out.', wptexturize( 'A dog ("Hubertus") was sent out.' ) ); … … 50 61 51 62 /** 52 63 * @ticket 4539 64 * 65 * @covers ::wptexturize 53 66 */ 54 67 function test_basic_quotes() { 55 68 $this->assertSame( 'test’s', wptexturize( 'test\'s' ) ); … … 73 86 /** 74 87 * @ticket 4539 75 88 * @ticket 15241 89 * 90 * @covers ::wptexturize 76 91 */ 77 92 function test_full_sentences_with_unmatched_single_quotes() { 78 93 $this->assertSame( … … 83 98 84 99 /** 85 100 * @ticket 4539 101 * 102 * @covers ::wptexturize 86 103 */ 87 104 function test_quotes() { 88 105 $this->assertSame( '“Quoted String”', wptexturize( '"Quoted String"' ) ); … … 102 119 103 120 /** 104 121 * @ticket 4539 122 * 123 * @covers ::wptexturize 105 124 */ 106 125 function test_quotes_before_s() { 107 126 $this->assertSame( 'test’s', wptexturize( "test's" ) ); … … 113 132 114 133 /** 115 134 * @ticket 4539 135 * 136 * @covers ::wptexturize 116 137 */ 117 138 function test_quotes_before_numbers() { 118 139 $this->assertSame( 'Class of ’99', wptexturize( "Class of '99" ) ); … … 141 162 $this->assertSame( '}”Class of ’99″{', wptexturize( "}\"Class of '99\"{" ) ); 142 163 } 143 164 165 /** 166 * @covers ::wptexturize 167 */ 144 168 function test_quotes_after_numbers() { 145 169 $this->assertSame( 'Class of ’99', wptexturize( "Class of '99" ) ); 146 170 } … … 148 172 /** 149 173 * @ticket 4539 150 174 * @ticket 15241 175 * 176 * @covers ::wptexturize 151 177 */ 152 178 function test_other_html() { 153 179 $this->assertSame( '‘<strong>', wptexturize( "'<strong>" ) ); … … 155 181 // $this->assertSame( '“<strong>Quoted Text</strong>”,', wptexturize( '"<strong>Quoted Text</strong>",' ) ); 156 182 } 157 183 184 /** 185 * @covers ::wptexturize 186 */ 158 187 function test_x() { 159 188 $this->assertSame( '14×24', wptexturize( '14x24' ) ); 160 189 } 161 190 191 /** 192 * @covers ::wptexturize 193 */ 162 194 function test_minutes_seconds() { 163 195 $this->assertSame( '9′', wptexturize( '9\'' ) ); 164 196 $this->assertSame( '9″', wptexturize( '9"' ) ); … … 172 204 173 205 /** 174 206 * @ticket 8775 207 * 208 * @covers ::wptexturize 175 209 */ 176 210 function test_wptexturize_quotes_around_numbers() { 177 211 $this->assertSame( '“12345”', wptexturize( '"12345"' ) ); … … 182 216 183 217 /** 184 218 * @ticket 8912 219 * 220 * @covers ::wptexturize 185 221 */ 186 222 function test_wptexturize_html_comments() { 187 223 $this->assertSame( '<!--[if !IE]>--><!--<![endif]-->', wptexturize( '<!--[if !IE]>--><!--<![endif]-->' ) ); … … 192 228 /** 193 229 * @ticket 4539 194 230 * @ticket 15241 231 * 232 * @covers ::wptexturize 195 233 */ 196 234 function test_entity_quote_cuddling() { 197 235 $this->assertSame( ' “Testing”', wptexturize( ' "Testing"' ) ); … … 200 238 201 239 /** 202 240 * @ticket 22823 241 * 242 * @covers ::wptexturize 203 243 */ 204 244 function test_apostrophes_before_primes() { 205 245 $this->assertSame( 'WordPress 3.5’s release date', wptexturize( "WordPress 3.5's release date" ) ); … … 207 247 208 248 /** 209 249 * @ticket 23185 250 * 251 * @covers ::wptexturize 210 252 */ 211 253 function test_spaces_around_hyphens() { 212 254 $nbsp = "\xC2\xA0"; … … 230 272 231 273 /** 232 274 * @ticket 31030 275 * 276 * @covers ::wptexturize 233 277 */ 234 278 function test_hyphens_at_start_and_end() { 235 279 $this->assertSame( '– ', wptexturize( '- ' ) ); … … 247 291 * These should never happen, even if the desired output changes some day. 248 292 * 249 293 * @ticket 22692 294 * 295 * @covers ::wptexturize 250 296 */ 251 297 function test_spaces_around_quotes_never() { 252 298 $nbsp = "\xC2\xA0"; … … 264 310 * 265 311 * @ticket 22692 266 312 * @dataProvider data_spaces_around_quotes 313 * 314 * @covers ::wptexturize 267 315 */ 268 316 function test_spaces_around_quotes( $input, $output ) { 269 317 return $this->assertSame( $output, wptexturize( $input ) ); … … 320 368 * 321 369 * @ticket 22692 322 370 * @dataProvider data_apos_before_digits 371 * 372 * @covers ::wptexturize 323 373 */ 324 374 function test_apos_before_digits( $input, $output ) { 325 375 return $this->assertSame( $output, wptexturize( $input ) ); … … 361 411 * 362 412 * @ticket 22692 363 413 * @dataProvider data_opening_single_quote 414 * 415 * @covers ::wptexturize 364 416 */ 365 417 function test_opening_single_quote( $input, $output ) { 366 418 return $this->assertSame( $output, wptexturize( $input ) ); … … 490 542 * 491 543 * @ticket 22692 492 544 * @dataProvider data_double_prime 545 * 546 * @covers ::wptexturize 493 547 */ 494 548 function test_double_prime( $input, $output ) { 495 549 return $this->assertSame( $output, wptexturize( $input ) ); … … 523 577 * 524 578 * @ticket 22692 525 579 * @dataProvider data_single_prime 580 * 581 * @covers ::wptexturize 526 582 */ 527 583 function test_single_prime( $input, $output ) { 528 584 return $this->assertSame( $output, wptexturize( $input ) ); … … 556 612 * 557 613 * @ticket 22692 558 614 * @dataProvider data_contractions 615 * 616 * @covers ::wptexturize 559 617 */ 560 618 function test_contractions( $input, $output ) { 561 619 return $this->assertSame( $output, wptexturize( $input ) ); … … 597 655 * 598 656 * @ticket 22692 599 657 * @dataProvider data_opening_quote 658 * 659 * @covers ::wptexturize 600 660 */ 601 661 function test_opening_quote( $input, $output ) { 602 662 return $this->assertSame( $output, wptexturize( $input ) ); … … 674 734 * 675 735 * @ticket 22692 676 736 * @dataProvider data_closing_quote 737 * 738 * @covers ::wptexturize 677 739 */ 678 740 function test_closing_quote( $input, $output ) { 679 741 return $this->assertSame( $output, wptexturize( $input ) ); … … 763 825 * 764 826 * @ticket 22692 765 827 * @dataProvider data_closing_single_quote 828 * 829 * @covers ::wptexturize 766 830 */ 767 831 function test_closing_single_quote( $input, $output ) { 768 832 return $this->assertSame( $output, wptexturize( $input ) ); … … 853 917 * @ticket 22692 854 918 * @ticket 30445 855 919 * @dataProvider data_multiplication 920 * 921 * @covers ::wptexturize 856 922 */ 857 923 function test_multiplication( $input, $output ) { 858 924 return $this->assertSame( $output, wptexturize( $input ) ); … … 903 969 * 904 970 * @ticket 22692 905 971 * @dataProvider data_ampersand 972 * 973 * @covers ::wptexturize 906 974 */ 907 975 function test_ampersand( $input, $output ) { 908 976 return $this->assertSame( $output, wptexturize( $input ) ); … … 968 1036 * 969 1037 * @ticket 22692 970 1038 * @dataProvider data_cockney 1039 * 1040 * @covers ::wptexturize 971 1041 */ 972 1042 function test_cockney( $input, $output ) { 973 1043 return $this->assertSame( $output, wptexturize( $input ) ); … … 1029 1099 * 1030 1100 * @ticket 22692 1031 1101 * @dataProvider data_smart_dashes 1102 * 1103 * @covers ::wptexturize 1032 1104 */ 1033 1105 function test_smart_dashes( $input, $output ) { 1034 1106 return $this->assertSame( $output, wptexturize( $input ) ); … … 1082 1154 * 1083 1155 * @ticket 22692 1084 1156 * @dataProvider data_misc_static_replacements 1157 * 1158 * @covers ::wptexturize 1085 1159 */ 1086 1160 function test_misc_static_replacements( $input, $output ) { 1087 1161 return $this->assertSame( $output, wptexturize( $input ) ); … … 1137 1211 * 1138 1212 * @ticket 8775 1139 1213 * @dataProvider data_quoted_numbers 1214 * 1215 * @covers ::wptexturize 1140 1216 */ 1141 1217 function test_quoted_numbers( $input, $output ) { 1142 1218 return $this->assertSame( $output, wptexturize( $input ) ); … … 1188 1264 * 1189 1265 * @ticket 20342 1190 1266 * @dataProvider data_quotes_and_dashes 1267 * 1268 * @covers ::wptexturize 1191 1269 */ 1192 1270 function test_quotes_and_dashes( $input, $output ) { 1193 1271 return $this->assertSame( $output, wptexturize( $input ) ); … … 1251 1329 * 1252 1330 * @ticket 12690 1253 1331 * @dataProvider data_tag_avoidance 1332 * 1333 * @covers ::wptexturize 1254 1334 */ 1255 1335 function test_tag_avoidance( $input, $output ) { 1256 1336 return $this->assertSame( $output, wptexturize( $input ) ); … … 1474 1554 * 1475 1555 * @ticket 26850 1476 1556 * @dataProvider data_year_abbr 1557 * 1558 * @covers ::wptexturize 1477 1559 */ 1478 1560 function test_year_abbr( $input, $output ) { 1479 1561 return $this->assertSame( $output, wptexturize( $input ) ); … … 1563 1645 * 1564 1646 * @ticket 27426 1565 1647 * @dataProvider data_translate 1648 * 1649 * @covers ::wptexturize 1566 1650 */ 1567 1651 function test_translate( $input, $output ) { 1568 1652 add_filter( 'gettext_with_context', array( $this, 'filter_translate' ), 10, 4 ); … … 1790 1874 * 1791 1875 * @ticket 28483 1792 1876 * @dataProvider data_element_stack 1877 * 1878 * @covers ::wptexturize 1793 1879 */ 1794 1880 function test_element_stack( $input, $output ) { 1795 1881 return $this->assertSame( $output, wptexturize( $input ) ); … … 1841 1927 * 1842 1928 * @ticket 29557 1843 1929 * @dataProvider data_unregistered_shortcodes 1930 * 1931 * @covers ::wptexturize 1844 1932 */ 1845 1933 function test_unregistered_shortcodes( $input, $output ) { 1846 1934 add_filter( 'no_texturize_shortcodes', array( $this, 'filter_shortcodes' ), 10, 1 ); … … 1926 2014 * 1927 2015 * @ticket 29256 1928 2016 * @dataProvider data_primes_vs_quotes 2017 * 2018 * @covers ::wptexturize 1929 2019 */ 1930 2020 function test_primes_vs_quotes( $input, $output ) { 1931 2021 return $this->assertSame( $output, wptexturize( $input ) ); … … 1988 2078 * 1989 2079 * @ticket 29256 1990 2080 * @dataProvider data_primes_quotes_translation 2081 * 2082 * @covers ::wptexturize 1991 2083 */ 1992 2084 function test_primes_quotes_translation( $input, $output ) { 1993 2085 add_filter( 'gettext_with_context', array( $this, 'filter_translate2' ), 10, 4 ); … … 2081 2173 * Automated performance testing of the main regex. 2082 2174 * 2083 2175 * @dataProvider data_whole_posts 2176 * 2177 * @covers ::preg_split 2084 2178 */ 2085 2179 function test_pcre_performance( $input ) { 2086 2180 global $shortcode_tags; … … 2101 2195 * Ensure that a trailing less-than symbol doesn't cause a PHP warning. 2102 2196 * 2103 2197 * @ticket 35864 2198 * 2199 * @covers ::wptexturize 2104 2200 */ 2105 2201 function test_trailing_less_than() { 2106 2202 $this->assertSame( 'F–oo<', wptexturize( 'F--oo<', true ) ); -
tests/phpunit/tests/formatting/WpTrimExcerpt.php
7 7 class Tests_Formatting_WpTrimExcerpt extends WP_UnitTestCase { 8 8 /** 9 9 * @ticket 25349 10 * 11 * @covers ::wp_trim_excerpt 10 12 */ 11 13 public function test_secondary_loop_respect_more() { 12 14 $post1 = self::factory()->post->create( … … 38 40 39 41 /** 40 42 * @ticket 25349 43 * 44 * @covers ::wp_trim_excerpt 41 45 */ 42 46 public function test_secondary_loop_respect_nextpage() { 43 47 $post1 = self::factory()->post->create( … … 69 73 70 74 /** 71 75 * @ticket 51042 76 * 77 * @covers ::wp_trim_excerpt 72 78 */ 73 79 public function test_should_generate_excerpt_for_empty_values() { 74 80 $post = self::factory()->post->create( -
tests/phpunit/tests/formatting/WPTrimWords.php
14 14 */ 15 15 private $long_text = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce varius lacinia vehicula. Etiam sapien risus, ultricies ac posuere eu, convallis sit amet augue. Pellentesque urna massa, lacinia vel iaculis eget, bibendum in mauris. Aenean eleifend pulvinar ligula, a convallis eros gravida non. Suspendisse potenti. Pellentesque et odio tortor. In vulputate pellentesque libero, sed dapibus velit mollis viverra. Pellentesque id urna euismod dolor cursus sagittis.'; 16 16 17 /** 18 * @covers ::wp_trim_words 19 */ 17 20 function test_trims_to_55_by_default() { 18 21 $trimmed = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce varius lacinia vehicula. Etiam sapien risus, ultricies ac posuere eu, convallis sit amet augue. Pellentesque urna massa, lacinia vel iaculis eget, bibendum in mauris. Aenean eleifend pulvinar ligula, a convallis eros gravida non. Suspendisse potenti. Pellentesque et odio tortor. In vulputate pellentesque libero, sed dapibus velit…'; 19 22 $this->assertSame( $trimmed, wp_trim_words( $this->long_text ) ); 20 23 } 21 24 25 /** 26 * @covers ::wp_trim_words 27 */ 22 28 function test_trims_to_10() { 23 29 $trimmed = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce varius…'; 24 30 $this->assertSame( $trimmed, wp_trim_words( $this->long_text, 10 ) ); 25 31 } 26 32 33 /** 34 * @covers ::wp_trim_words 35 */ 27 36 function test_trims_to_5_and_uses_custom_more() { 28 37 $trimmed = 'Lorem ipsum dolor sit amet,[...] Read on!'; 29 38 $this->assertSame( $trimmed, wp_trim_words( $this->long_text, 5, '[...] Read on!' ) ); 30 39 } 31 40 41 /** 42 * @covers ::wp_trim_words 43 */ 32 44 function test_strips_tags_before_trimming() { 33 45 $text = 'This text contains a <a href="http://wordpress.org"> link </a> to WordPress.org!'; 34 46 $trimmed = 'This text contains a link…'; … … 37 49 38 50 /** 39 51 * @ticket 18726 52 * 53 * @covers ::wp_trim_words 40 54 */ 41 55 function test_strips_script_and_style_content() { 42 56 $trimmed = 'This text contains. It should go.'; … … 48 62 $this->assertSame( $trimmed, wp_trim_words( $text ) ); 49 63 } 50 64 65 /** 66 * @covers ::wp_trim_words 67 */ 51 68 function test_doesnt_trim_short_text() { 52 69 $text = 'This is some short text.'; 53 70 $this->assertSame( $text, wp_trim_words( $text ) ); … … 55 72 56 73 /** 57 74 * @ticket 44541 75 * 76 * @covers ::wp_trim_words 58 77 */ 59 78 function test_trims_to_20_counted_by_chars() { 60 79 switch_to_locale( 'ja_JP' ); … … 66 85 67 86 /** 68 87 * @ticket 44541 88 * 89 * @covers ::wp_trim_words 69 90 */ 70 91 function test_trims_to_20_counted_by_chars_with_double_width_chars() { 71 92 switch_to_locale( 'ja_JP' ); … … 78 99 79 100 /** 80 101 * @ticket 47867 102 * 103 * @covers ::wp_trim_words 81 104 */ 82 105 function test_works_with_non_numeric_num_words() { 83 106 $this->assertSame( '', wp_trim_words( $this->long_text, '', '' ) ); -
tests/phpunit/tests/formatting/Zeroise.php
4 4 * @group formatting 5 5 */ 6 6 class Tests_Formatting_Zeroise extends WP_UnitTestCase { 7 8 /** 9 * @covers ::zeroise 10 */ 7 11 function test_pads_with_leading_zeroes() { 8 12 $this->assertSame( '00005', zeroise( 5, 5 ) ); 9 13 } 10 14 15 /** 16 * @covers ::zeroise 17 */ 11 18 function test_does_nothing_if_input_is_already_longer() { 12 19 $this->assertSame( '5000000', zeroise( 5000000, 2 ) ); 13 20 }