Make WordPress Core

Ticket #39265: formatting.patch

File formatting.patch, 101.0 KB (added by pbearne, 4 years ago)

the formatting folder

  • tests/phpunit/tests/formatting/Autop.php

     
    77
    88        /**
    99         * @ticket 11008
     10         *
     11         * @covers ::autop
    1012         */
    1113        function test_first_post() {
    1214                $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>
     
    6971         * wpautop() Should not alter the contents of "<pre>" elements
    7072         *
    7173         * @ticket 19855
     74         *
     75         * @covers ::autop
    7276         */
    7377        public function test_skip_pre_elements() {
    7478                $code = file_get_contents( DIR_TESTDATA . '/formatting/sizzle.js' );
     
    96100         * wpautop() Should not add <br/> to "<input>" elements
    97101         *
    98102         * @ticket 16456
     103         *
     104         * @covers ::autop
    99105         */
    100106        public function test_skip_input_elements() {
    101107                $str = 'Username: <input type="text" id="username" name="username" /><br />Password: <input type="password" id="password1" name="password1" />';
     
    106112         * wpautop() Should not add <p> and <br/> around <source> and <track>
    107113         *
    108114         * @ticket 26864
     115         *
     116         * @covers ::autop
    109117         */
    110118        public function test_source_track_elements() {
    111119                $content = "Paragraph one.\n\n" .
     
    192200         * wpautop() Should not add <p> and <br/> around <param> and <embed>
    193201         *
    194202         * @ticket 26864
     203         *
     204         * @covers ::autop
    195205         */
    196206        public function test_param_embed_elements() {
    197207                $content1 = '
     
    271281         * wpautop() Should not add <br/> to "<select>" or "<option>" elements
    272282         *
    273283         * @ticket 22230
     284         *
     285         * @covers ::autop
    274286         */
    275287        public function test_skip_select_option_elements() {
    276288                $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>';
     
    281293         * wpautop() should treat block level HTML elements as blocks.
    282294         *
    283295         * @ticket 27268
     296         *
     297         * @covers ::autop
    284298         */
    285299        function test_that_wpautop_treats_block_level_elements_as_blocks() {
    286300                $blocks = array(
     
    387401         * wpautop() should treat inline HTML elements as inline.
    388402         *
    389403         * @ticket 27268
     404         *
     405         * @covers ::autop
    390406         */
    391407        function test_that_wpautop_treats_inline_elements_as_inline() {
    392408                $inlines = array(
     
    437453         *
    438454         * @ticket 33106
    439455         * @dataProvider data_element_sanity
     456         *
     457         * @covers ::autop
    440458         */
    441459        function test_element_sanity( $input, $output ) {
    442460                return $this->assertSame( $output, wpautop( $input ) );
     
    489507         * wpautop() should not convert line breaks after <br /> tags
    490508         *
    491509         * @ticket 33377
     510         *
     511         * @covers ::autop
    492512         */
    493513        function test_that_wpautop_skips_line_breaks_after_br() {
    494514                $content = '
     
    512532         * wpautop() should convert multiple line breaks into a paragraph regarless of <br /> format
    513533         *
    514534         * @ticket 33377
     535         *
     536         * @covers ::autop
    515537         */
    516538        function test_that_wpautop_adds_a_paragraph_after_multiple_br() {
    517539                $content = '
     
    530552
    531553        /**
    532554         * @ticket 4857
     555         *
     556         * @covers ::autop
    533557         */
    534558        function test_that_text_before_blocks_is_peed() {
    535559                $content  = 'a<div>b</div>';
     
    545569         * @uses ::trim
    546570         *
    547571         * @ticket 39307
     572         *
     573         * @covers ::autop
    548574         */
    549575        function test_that_wpautop_does_not_add_extra_closing_p_in_figure() {
    550576                $content1  = '<figure><img src="example.jpg" /><figcaption>Caption</figcaption></figure>';
     
    564590
    565591        /**
    566592         * @ticket 14674
     593         *
     594         * @covers ::autop
    567595         */
    568596        function test_the_hr_is_not_peed() {
    569597                $content  = 'paragraph1<hr>paragraph2';
     
    576604         * wpautop() should ignore inline SVG graphics
    577605         *
    578606         * @ticket 9437
     607         *
     608         * @covers ::autop
    579609         */
    580610        function test_that_wpautop_ignores_inline_svgs() {
    581611                $content =
     
    594624         * wpautop() should ignore inline scripts
    595625         *
    596626         * @ticket 9437
     627         *
     628         * @covers ::autop
    597629         */
    598630        function test_that_wpautop_ignores_inline_scripts() {
    599631                $content =
  • tests/phpunit/tests/formatting/balanceTags.php

     
    150150        /**
    151151         * @ticket 47014
    152152         * @dataProvider supported_traditional_tag_names
     153         *
     154         * @covers ::balanceTags
    153155         */
    154156        function test_detects_traditional_tag_names( $tag ) {
    155157                $normalized = strtolower( $tag );
     
    160162        /**
    161163         * @ticket 47014
    162164         * @dataProvider supported_custom_element_tag_names
     165         *
     166         * @covers ::balanceTags
    163167         */
    164168        function test_detects_supported_custom_element_tag_names( $tag ) {
    165169                $this->assertSame( "<$tag>inside</$tag>", balanceTags( "<$tag>inside", true ) );
     
    168172        /**
    169173         * @ticket 47014
    170174         * @dataProvider invalid_tag_names
     175         *
     176         * @covers ::balanceTags
    171177         */
    172178        function test_ignores_invalid_tag_names( $input, $output ) {
    173179                $this->assertSame( $output, balanceTags( $input, true ) );
     
    176182        /**
    177183         * @ticket 47014
    178184         * @dataProvider unsupported_valid_tag_names
     185         *
     186         * @covers ::balanceTags
    179187         */
    180188        function test_ignores_unsupported_custom_tag_names( $tag ) {
    181189                $this->assertSame( "<$tag>inside", balanceTags( "<$tag>inside", true ) );
     
    184192        /**
    185193         * @ticket 47014
    186194         * @dataProvider supported_invalid_tag_names
     195         *
     196         * @covers ::balanceTags
    187197         */
    188198        function test_detects_supported_invalid_tag_names( $tag ) {
    189199                $this->assertSame( "<$tag>inside</$tag>", balanceTags( "<$tag>inside", true ) );
     
    194204         *
    195205         * @ticket 1597
    196206         * @dataProvider single_tags
     207         *
     208         * @covers ::balanceTags
    197209         */
    198210        function test_selfcloses_unclosed_known_single_tags( $tag ) {
    199211                $this->assertSame( "<$tag />", balanceTags( "<$tag>", true ) );
     
    205217         *
    206218         * @ticket 1597
    207219         * @dataProvider single_tags
     220         *
     221         * @covers ::balanceTags
    208222         */
    209223        function test_selfcloses_known_single_tags_having_closing_tag( $tag ) {
    210224                $this->assertSame( "<$tag />", balanceTags( "<$tag></$tag>", true ) );
     
    212226
    213227        /**
    214228         * @ticket 1597
     229         *
     230         * @covers ::balanceTags
    215231         */
    216232        function test_closes_unknown_single_tags_with_closing_tag() {
    217233
     
    236252                }
    237253        }
    238254
     255        /**
     256         * @covers ::balanceTags
     257         */
    239258        function test_closes_unclosed_single_tags_having_attributes() {
    240259                $inputs   = array(
    241260                        '<img src="/images/example.png">',
     
    251270                }
    252271        }
    253272
     273        /**
     274         * @covers ::balanceTags
     275         */
    254276        function test_allows_validly_closed_single_tags() {
    255277                $inputs = array(
    256278                        '<br />',
     
    266288
    267289        /**
    268290         * @dataProvider nestable_tags
     291         *
     292         * @covers ::balanceTags
    269293         */
    270294        function test_balances_nestable_tags( $tag ) {
    271295                $inputs   = array(
     
    284308                }
    285309        }
    286310
     311        /**
     312         * @covers ::balanceTags
     313         */
    287314        function test_allows_adjacent_nestable_tags() {
    288315                $inputs = array(
    289316                        '<blockquote><blockquote>Example quote</blockquote></blockquote>',
     
    300327
    301328        /**
    302329         * @ticket 20401
     330         *
     331         * @covers ::balanceTags
    303332         */
    304333        function test_allows_immediately_nested_object_tags() {
    305334                $object = '<object id="obj1"><param name="param1"/><object id="obj2"><param name="param2"/></object></object>';
     
    306335                $this->assertSame( $object, balanceTags( $object, true ) );
    307336        }
    308337
     338        /**
     339         * @covers ::balanceTags
     340         */
    309341        function test_balances_nested_non_nestable_tags() {
    310342                $inputs   = array(
    311343                        '<b><b>This is bold</b></b>',
     
    321353                }
    322354        }
    323355
     356        /**
     357         * @covers ::balanceTags
     358         */
    324359        function test_fixes_improper_closing_tag_sequence() {
    325360                $inputs   = array(
    326361                        '<p>Here is a <strong class="part">bold <em>and emphasis</p></em></strong>',
     
    336371                }
    337372        }
    338373
     374        /**
     375         * @covers ::balanceTags
     376         */
    339377        function test_adds_missing_closing_tags() {
    340378                $inputs   = array(
    341379                        '<b><i>Test</b>',
     
    357395                }
    358396        }
    359397
     398        /**
     399         * @covers ::balanceTags
     400         */
    360401        function test_removes_extraneous_closing_tags() {
    361402                $inputs   = array(
    362403                        '<b>Test</b></b>',
     
    436477         *
    437478         * @param string $source   Source.
    438479         * @param string $expected Expected.
     480         *
     481         * @covers ::balanceTags
    439482         */
    440483        public function test_custom_elements( $source, $expected ) {
    441484                $this->assertSame( $expected, balanceTags( $source, true ) );
  • tests/phpunit/tests/formatting/BlogInfo.php

     
    88        /**
    99         * @dataProvider locales
    1010         * @ticket 28303
     11         *
     12         * @covers ::get_bloginfo
    1113         */
    1214        function test_get_bloginfo_language( $test_locale, $expected ) {
    1315                global $locale;
     
    3537
    3638        /**
    3739         * @ticket 27942
     40         *
     41         * @covers ::get_bloginfo
    3842         */
    3943        function test_bloginfo_sanitize_option() {
    4044                $old_values = array(
  • tests/phpunit/tests/formatting/CapitalPDangit.php

     
    33
    44/**
    55 * @group formatting
     6 *
     7 * @covers ::capital_P_dangit
    68 */
    79class Tests_Formatting_CapitalPDangit extends WP_UnitTestCase {
    810        function test_esc_attr_quotes() {
  • tests/phpunit/tests/formatting/CleanPre.php

     
    99 */
    1010class Tests_Formatting_CleanPre extends WP_UnitTestCase {
    1111
     12        /**
     13         * @covers ::clean_pre
     14         */
    1215        function test_removes_self_closing_br_with_space() {
    1316                $source = 'a b c\n<br />sldfj<br />';
    1417                $res    = 'a b c\nsldfj';
     
    1619                $this->assertSame( $res, clean_pre( $source ) );
    1720        }
    1821
     22        /**
     23         * @covers ::clean_pre
     24         */
    1925        function test_removes_self_closing_br_without_space() {
    2026                $source = 'a b c\n<br/>sldfj<br/>';
    2127                $res    = 'a b c\nsldfj';
     
    2228                $this->assertSame( $res, clean_pre( $source ) );
    2329        }
    2430
    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         */
    2940        function test_removes_html_br() {
    3041                $source = 'a b c\n<br>sldfj<br>';
    3142                $res    = 'a b c\nsldfj';
     
    3243                $this->assertSame( $res, clean_pre( $source ) );
    3344        }
    3445
     46        /**
     47         * @covers ::clean_pre
     48         */
    3549        function test_removes_p() {
    3650                $source = "<p>isn't this exciting!</p><p>oh indeed!</p>";
    3751                $res    = "\nisn't this exciting!\noh indeed!";
  • tests/phpunit/tests/formatting/ConvertInvalidEntries.php

     
    44 * @group formatting
    55 */
    66class Tests_Formatting_ConvertInvalidEntities extends WP_UnitTestCase {
     7
     8        /**
     9         * @covers ::convert_invalid_entities
     10         */
    711        function test_replaces_windows1252_entities_with_unicode_ones() {
    812                $input  = '&#130;&#131;&#132;&#133;&#134;&#135;&#136;&#137;&#138;&#139;&#140;&#145;&#146;&#147;&#148;&#149;&#150;&#151;&#152;&#153;&#154;&#155;&#156;&#159;';
    913                $output = '&#8218;&#402;&#8222;&#8230;&#8224;&#8225;&#710;&#8240;&#352;&#8249;&#338;&#8216;&#8217;&#8220;&#8221;&#8226;&#8211;&#8212;&#732;&#8482;&#353;&#8250;&#339;&#376;';
     
    1216
    1317        /**
    1418         * @ticket 20503
     19         *
     20         * @covers ::convert_invalid_entities
    1521         */
    1622        function test_replaces_latin_letter_z_with_caron() {
    1723                $input  = '&#142;&#158;';
     
    1925                $this->assertSame( $output, convert_invalid_entities( $input ) );
    2026        }
    2127
     28        /**
     29         * @covers ::convert_invalid_entities
     30         */
    2231        function test_escapes_lone_ampersands() {
    2332                $this->assertSame( 'at&#038;t', convert_chars( 'at&t' ) );
    2433        }
  • tests/phpunit/tests/formatting/date.php

     
    1010         * Unpatched, this test passes only when Europe/London is not observing DST.
    1111         *
    1212         * @ticket 20328
     13         *
     14         * @covers ::get_date_from_gmt
    1315         */
    1416        function test_get_date_from_gmt_outside_of_dst() {
    1517                update_option( 'timezone_string', 'Europe/London' );
     
    2224         * Unpatched, this test passes only when Europe/London is observing DST.
    2325         *
    2426         * @ticket 20328
     27         *
     28         * @covers ::get_date_from_gmt
    2529         */
    2630        function test_get_date_from_gmt_during_dst() {
    2731                update_option( 'timezone_string', 'Europe/London' );
     
    3236
    3337        /**
    3438         * @ticket 20328
     39         *
     40         * @covers ::get_gmt_from_date
    3541         */
    3642        function test_get_gmt_from_date_outside_of_dst() {
    3743                update_option( 'timezone_string', 'Europe/London' );
     
    4248
    4349        /**
    4450         * @ticket 20328
     51         *
     52         * @covers ::get_gmt_from_date
    4553         */
    4654        function test_get_gmt_from_date_during_dst() {
    4755                update_option( 'timezone_string', 'Europe/London' );
     
    5260
    5361        /**
    5462         * @ticket 34279
     63         *
     64         * @covers ::get_date_from_gmt
     65         *
    5566         */
    5667        function test_get_date_and_time_from_gmt_no_timezone() {
    5768                $local = '2012-01-01 12:34:56';
     
    6172
    6273        /**
    6374         * @ticket 34279
     75         *
     76         * @covers ::get_gmt_from_date
    6477         */
    6578        function test_get_gmt_from_date_no_timezone() {
    6679                $gmt  = '2012-12-01 00:00:00';
     
    7083
    7184        /**
    7285         * @ticket 34279
     86         *
     87         * @covers ::get_gmt_from_date
    7388         */
    7489        function test_get_gmt_from_date_short_date() {
    7590                update_option( 'timezone_string', 'Europe/London' );
     
    8095
    8196        /**
    8297         * @ticket 34279
     98         *
     99         * @covers ::get_gmt_from_date
    83100         */
    84101        function test_get_gmt_from_date_string_date() {
    85102                update_option( 'timezone_string', 'Europe/London' );
     
    90107
    91108        /**
    92109         * @ticket 34279
     110         *
     111         * @covers ::get_gmt_from_date
    93112         */
    94113        function test_get_gmt_from_date_string_date_no_timezone() {
    95114                $local = 'now';
     
    101120         * @ticket 31809
    102121         *
    103122         * @dataProvider timezone_provider
     123         *
     124         * @covers ::get_gmt_from_date
    104125         */
    105126        public function test_gmt_from_date_correct_time( $timezone_string, $gmt_offset ) {
    106127                update_option( 'timezone_string', $timezone_string );
     
    117138         * @ticket 31809
    118139         *
    119140         * @dataProvider timezone_provider
     141         *
     142         * @covers ::get_date_from_gmt
    120143         */
    121144        public function test_date_from_gmt_correct_time( $timezone_string, $gmt_offset ) {
    122145                update_option( 'timezone_string', $timezone_string );
     
    133156         * @ticket 31809
    134157         *
    135158         * @dataProvider timezone_provider
     159         *
     160         * @covers ::iso8601_to_datetime
    136161         */
    137162        public function test_is8601_to_datetime_correct_time( $timezone_string, $gmt_offset ) {
    138163                update_option( 'timezone_string', $timezone_string );
  • tests/phpunit/tests/formatting/Emoji.php

     
    1111
    1212        /**
    1313         * @ticket 36525
     14         *
     15         * @covers ::_print_emoji_detection_script
    1416         */
    1517        public function test_unfiltered_emoji_cdns() {
    1618                $output = get_echo( '_print_emoji_detection_script' );
     
    2527
    2628        /**
    2729         * @ticket 36525
     30         *
     31         * @covers ::_print_emoji_detection_script
    2832         */
    2933        public function test_filtered_emoji_svn_cdn() {
    3034                $filtered_svn_cdn = $this->_filtered_emoji_svn_cdn();
     
    4650
    4751        /**
    4852         * @ticket 36525
     53         *
     54         * @covers ::_print_emoji_detection_script
    4955         */
    5056        public function test_filtered_emoji_png_cdn() {
    5157                $filtered_png_cdn = $this->_filtered_emoji_png_cdn();
     
    6369
    6470        /**
    6571         * @ticket 41501
     72         *
     73         * @covers ::_wp_emoji_list
    6674         */
    6775        public function test_wp_emoji_list_returns_data() {
    6876                $default = _wp_emoji_list();
     
    107115        /**
    108116         * @ticket 35293
    109117         * @dataProvider data_wp_encode_emoji
     118         *
     119         * @covers ::wp_encode_emoji
    110120         */
    111121        public function test_wp_encode_emoji( $emoji, $expected ) {
    112122                $this->assertSame( $expected, wp_encode_emoji( $emoji ) );
     
    142152        /**
    143153         * @ticket 35293
    144154         * @dataProvider data_wp_staticize_emoji
     155         *
     156         * @covers ::wp_staticize_emoji
    145157         */
    146158        public function test_wp_staticize_emoji( $emoji, $expected ) {
    147159                $this->assertSame( $expected, wp_staticize_emoji( $emoji ) );
  • tests/phpunit/tests/formatting/ent2ncr.php

     
    66class Tests_Formatting_Ent2NCR extends WP_UnitTestCase {
    77        /**
    88         * @dataProvider entities
     9         *
     10         * @covers ::ent2ncr
    911         */
    1012        function test_converts_named_entities_to_numeric_character_references( $entity, $ncr ) {
    1113                $entity = '&' . $entity . ';';
  • tests/phpunit/tests/formatting/EscAttr.php

     
    44 * @group formatting
    55 */
    66class Tests_Formatting_EscAttr extends WP_UnitTestCase {
     7        /**
     8         * @covers ::esc_attr
     9         */
    710        function test_esc_attr_quotes() {
    811                $attr = '"double quotes"';
    912                $this->assertSame( '&quot;double quotes&quot;', esc_attr( $attr ) );
     
    2427                $attr = "'mixed' " . '"quotes"';
    2528                $this->assertSame( '&#039;mixed&#039; &quot;quotes&quot;', esc_attr( esc_attr( $attr ) ) );
    2629        }
    27 
     30        /**
     31         * @covers ::esc_attr
     32         */
    2833        function test_esc_attr_amp() {
    2934                $out = esc_attr( 'foo & bar &baz; &nbsp;' );
    3035                $this->assertSame( 'foo &amp; bar &amp;baz; &nbsp;', $out );
  • tests/phpunit/tests/formatting/EscHtml.php

     
    44 * @group formatting
    55 */
    66class Tests_Formatting_EscHtml extends WP_UnitTestCase {
     7
     8        /**
     9         * @covers ::esc_html
     10         */
    711        function test_esc_html_basics() {
    812                // Simple string.
    913                $html = 'The quick brown fox.';
     
    2024                $this->assertSame( $escaped, esc_html( $html ) );
    2125        }
    2226
     27        /**
     28         * @covers ::esc_html
     29         */
    2330        function test_escapes_ampersands() {
    2431                $source = 'penn & teller & at&t';
    2532                $res    = 'penn &amp; teller &amp; at&amp;t';
     
    2633                $this->assertSame( $res, esc_html( $source ) );
    2734        }
    2835
     36        /**
     37         * @covers ::esc_html
     38         */
    2939        function test_escapes_greater_and_less_than() {
    3040                $source = 'this > that < that <randomhtml />';
    3141                $res    = 'this &gt; that &lt; that &lt;randomhtml /&gt;';
     
    3242                $this->assertSame( $res, esc_html( $source ) );
    3343        }
    3444
     45        /**
     46         * @covers ::esc_html
     47         */
    3548        function test_ignores_existing_entities() {
    3649                $source = '&#038; &#x00A3; &#x22; &amp;';
    3750                $res    = '&#038; &#xA3; &#x22; &amp;';
  • tests/phpunit/tests/formatting/EscTextarea.php

     
    1212        /*
    1313         * Only fails in PHP 5.4 onwards
    1414         * @ticket 23688
     15         *
     16         * @covers ::esc_textarea
    1517         */
    1618        function test_esc_textarea_charset_iso_8859_1() {
    1719                add_filter( 'pre_option_blog_charset', array( $this, '_charset_iso_8859_1' ) );
     
    2628
    2729        /*
    2830         * @ticket 23688
     31         *
     32         * @covers ::esc_textarea
    2933         */
    3034        function test_esc_textarea_charset_utf_8() {
    3135                add_filter( 'pre_option_blog_charset', array( $this, '_charset_utf_8' ) );
  • tests/phpunit/tests/formatting/EscUrl.php

     
    77
    88        /**
    99         * @ticket 23605
     10         *
     11         * @covers ::esc_url
    1012         */
    1113        function test_spaces() {
    1214                $this->assertSame( 'http://example.com/Mr%20WordPress', esc_url( 'http://example.com/Mr WordPress' ) );
     
    1921                $this->assertSame( 'http://example.com/?foo=one%20two%20three&#038;bar=four', esc_url( 'http://example.com/?foo=one%20two%20three&bar=four' ) );
    2022        }
    2123
     24        /**
     25         *
     26         * @covers ::esc_url
     27         */
    2228        function test_bad_characters() {
    2329                $this->assertSame( 'http://example.com/watchthelinefeedgo', esc_url( 'http://example.com/watchthelinefeed%0Ago' ) );
    2430                $this->assertSame( 'http://example.com/watchthelinefeedgo', esc_url( 'http://example.com/watchthelinefeed%0ago' ) );
     
    3339                $this->assertSame( 'http://example.com/', esc_url( 'http://example.com/%0%0%0ADa' ) );
    3440        }
    3541
     42        /**
     43         *
     44         * @covers ::esc_url
     45         */
    3646        function test_relative() {
    3747                $this->assertSame( '/example.php', esc_url( '/example.php' ) );
    3848                $this->assertSame( 'example.php', esc_url( 'example.php' ) );
     
    4050                $this->assertSame( '?foo=bar', esc_url( '?foo=bar' ) );
    4151        }
    4252
     53        /**
     54         *
     55         * @covers ::esc_url
     56         * @covers ::esc_url_raw
     57         */
    4358        function test_all_url_parts() {
    4459                $url = 'https://user:pass@host.example.com:1234/path;p=1?query=2&r[]=3#fragment';
    4560
     
    6075                $this->assertSame( 'https://user:pass@host.example.com:1234/path;p=1?query=2&#038;r%5B%5D=3#fragment', esc_url( $url ) );
    6176        }
    6277
     78        /**
     79         *
     80         * @covers ::esc_url
     81         */
    6382        function test_bare() {
    6483                $this->assertSame( 'http://example.com?foo', esc_url( 'example.com?foo' ) );
    6584                $this->assertSame( 'http://example.com', esc_url( 'example.com' ) );
     
    6887                $this->assertSame( 'http://баба.org/баба', esc_url( 'баба.org/баба' ) );
    6988        }
    7089
     90        /**
     91         *
     92         * @covers ::esc_url
     93         * @covers ::esc_url_raw
     94         */
    7195        function test_encoding() {
    7296                $this->assertSame( 'http://example.com?foo=1&bar=2', esc_url_raw( 'http://example.com?foo=1&bar=2' ) );
    7397                $this->assertSame( 'http://example.com?foo=1&amp;bar=2', esc_url_raw( 'http://example.com?foo=1&amp;bar=2' ) );
     
    81105                $this->assertSame( "http://example.com?url={$param}", esc_url( "http://example.com?url={$param}" ) );
    82106        }
    83107
     108        /**
     109         *
     110         * @covers ::esc_url
     111         * @covers ::esc_url_raw
     112         */
    84113        function test_protocol() {
    85114                $this->assertSame( 'http://example.com', esc_url( 'http://example.com' ) );
    86115                $this->assertSame( '', esc_url( 'nasty://example.com/' ) );
     
    145174
    146175        /**
    147176         * @ticket 23187
     177         *
     178         * @covers ::esc_url
    148179         */
    149180        function test_protocol_case() {
    150181                $this->assertSame( 'http://example.com', esc_url( 'HTTP://example.com' ) );
     
    151182                $this->assertSame( 'http://example.com', esc_url( 'Http://example.com' ) );
    152183        }
    153184
     185        /**
     186         *
     187         * @covers ::esc_url
     188         */
    154189        function test_display_extras() {
    155190                $this->assertSame( 'http://example.com/&#039;quoted&#039;', esc_url( 'http://example.com/\'quoted\'' ) );
    156191                $this->assertSame( 'http://example.com/\'quoted\'', esc_url( 'http://example.com/\'quoted\'', null, 'notdisplay' ) );
    157192        }
    158193
     194        /**
     195         *
     196         * @covers ::esc_url
     197         */
    159198        function test_non_ascii() {
    160199                $this->assertSame( 'http://example.org/баба', esc_url( 'http://example.org/баба' ) );
    161200                $this->assertSame( 'http://баба.org/баба', esc_url( 'http://баба.org/баба' ) );
     
    162201                $this->assertSame( 'http://müller.com/', esc_url( 'http://müller.com/' ) );
    163202        }
    164203
     204        /**
     205         *
     206         * @covers ::esc_url
     207         */
    165208        function test_feed() {
    166209                $this->assertSame( '', esc_url( 'feed:javascript:alert(1)' ) );
    167210                $this->assertSame( '', esc_url( 'feed:javascript:feed:alert(1)' ) );
     
    172215
    173216        /**
    174217         * @ticket 16859
     218         *
     219         * @covers ::esc_url
    175220         */
    176221        function test_square_brackets() {
    177222                $this->assertSame( '/example.php?one%5B%5D=two', esc_url( '/example.php?one[]=two' ) );
     
    187232
    188233        /**
    189234         * Courtesy of http://blog.lunatech.com/2009/02/03/what-every-web-developer-must-know-about-url-encoding
     235         *
     236         * @covers ::esc_url_raw
    190237         */
    191238        function test_reserved_characters() {
    192239                $url = "http://example.com/:@-._~!$&'()*+,=;:@-._~!$&'()*+,=:@-._~!$&'()*+,==?/?:@-._~!$%27()*+,;=/?:@-._~!$%27()*+,;==#/?:@-._~!$&'()*+,;=";
     
    195242
    196243        /**
    197244         * @ticket 21974
     245         *
     246         * @covers ::esc_url
    198247         */
    199248        function test_protocol_relative_with_colon() {
    200249                $this->assertSame( '//example.com/foo?foo=abc:def', esc_url( '//example.com/foo?foo=abc:def' ) );
     
    202251
    203252        /**
    204253         * @ticket 31632
     254         *
     255         * @covers ::esc_url
    205256         */
    206257        function test_mailto_with_newline() {
    207258                $body       = <<<EOT
     
    217268
    218269        /**
    219270         * @ticket 31632
     271         *
     272         * @covers ::esc_url
    220273         */
    221274        function test_mailto_in_http_url_with_newline() {
    222275                $body       = <<<EOT
     
    232285
    233286        /**
    234287         * @ticket 23605
     288         *
     289         * @covers ::esc_url
    235290         */
    236291        function test_mailto_with_spaces() {
    237292                $body = 'Hi there, I thought you might want to sign up for this newsletter';
     
    243298
    244299        /**
    245300         * @ticket 28015
     301         *
     302         * @covers ::esc_url_raw
    246303         */
    247304        function test_invalid_charaters() {
    248305                $this->assertEmpty( esc_url_raw( '"^<>{}`' ) );
     
    250307
    251308        /**
    252309         * @ticket 34202
     310         *
     311         * @covers ::esc_url
    253312         */
    254313        function test_ipv6_hosts() {
    255314                $this->assertSame( '//[::127.0.0.1]', esc_url( '//[::127.0.0.1]' ) );
  • tests/phpunit/tests/formatting/EscXml.php

     
    1111         *
    1212         * @param string $source   The source string to be escaped.
    1313         * @param string $expected The expected escaped value of `$source`.
     14         *
     15         * @covers ::esc_xml
    1416         */
    1517        public function test_esc_xml_basics( $source, $expected ) {
    1618                $actual = esc_xml( $source );
     
    4547                );
    4648        }
    4749
     50        /**
     51         *
     52         * @covers ::esc_xml
     53         */
    4854        public function test_escapes_ampersands() {
    4955                $source   = 'penn & teller & at&t';
    5056                $expected = 'penn &amp; teller &amp; at&amp;t';
     
    5258                $this->assertSame( $expected, $actual );
    5359        }
    5460
     61        /**
     62         *
     63         * @covers ::esc_xml
     64         */
    5565        public function test_escapes_greater_and_less_than() {
    5666                $source   = 'this > that < that <randomhtml />';
    5767                $expected = 'this &gt; that &lt; that &lt;randomhtml /&gt;';
     
    5969                $this->assertSame( $expected, $actual );
    6070        }
    6171
     72        /**
     73         *
     74         * @covers ::esc_xml
     75         */
    6276        public function test_escapes_html_named_entities() {
    6377                $source   = 'this &amp; is a &hellip; followed by &rsaquo; and more and a &nonexistent; entity';
    6478                $expected = 'this &amp; is a … followed by › and more and a &amp;nonexistent; entity';
     
    6680                $this->assertSame( $expected, $actual );
    6781        }
    6882
     83        /**
     84         *
     85         * @covers ::esc_xml
     86         */
    6987        public function test_ignores_existing_entities() {
    7088                $source = '&#038; &#x00A3; &#x22; &amp;';
    7189                // note that _wp_specialchars() strips leading 0's from numeric character references.
     
    8199         *
    82100         * @param string $source   The source string to be escaped.
    83101         * @param string $expected The expected escaped value of `$source`.
     102         *
     103         * @covers ::esc_xml
    84104         */
    85105        public function test_ignores_cdata_sections( $source, $expected ) {
    86106                $actual = esc_xml( $source );
  • tests/phpunit/tests/formatting/ExcerptRemoveBlocks.php

     
    2222        <!-- wp:column -->
    2323        <div class="wp-block-column">
    2424                <!-- wp:archives {"displayAsDropdown":false,"showPostCounts":false} /-->
    25                
     25
    2626                <!-- wp:paragraph -->
    2727                <p>paragraph inside column</p>
    2828                <!-- /wp:paragraph -->
     
    4040
    4141
    4242                <p>paragraph inside column</p>
    43                
     43
    4444';
    4545
    4646        /**
     
    9191         * Tests excerpt_remove_blocks().
    9292         *
    9393         * @ticket 46133
     94         *
     95         * @covers ::excerpt_remove_blocks
    9496         */
    9597        function test_excerpt_remove_blocks() {
    9698                // Simple dynamic block..
     
    116118         * `the_content` gets applied, just like shortcodes.
    117119         *
    118120         * @ticket 46133
     121         *
     122         * @covers ::do_blocks
    119123         */
    120124        function test_excerpt_infinite_loop() {
    121125                $query = new WP_Query(
  • tests/phpunit/tests/formatting/GetUrlInContent.php

     
    4343         * Validate the get_url_in_content function
    4444         *
    4545         * @dataProvider get_input_output
     46         *
     47         * @covers ::get_url_in_content
    4648         */
    4749        function test_get_url_in_content( $in_str, $exp_str ) {
    4850                $this->assertSame( $exp_str, get_url_in_content( $in_str ) );
  • tests/phpunit/tests/formatting/HtmlExcerpt.php

     
    44 * @group formatting
    55 */
    66class Tests_Formatting_HtmlExcerpt extends WP_UnitTestCase {
     7
     8        /**
     9         * @covers ::wp_html_excerpt
     10         */
    711        function test_simple() {
    812                $this->assertSame( 'Baba', wp_html_excerpt( 'Baba told me not to come', 4 ) );
    913        }
     14
     15        /**
     16         * @covers ::wp_html_excerpt
     17         */
    1018        function test_html() {
    1119                $this->assertSame( 'Baba', wp_html_excerpt( "<a href='http://baba.net/'>Baba</a> told me not to come", 4 ) );
    1220        }
     21
     22        /**
     23         * @covers ::wp_html_excerpt
     24         */
    1325        function test_entities() {
    1426                $this->assertSame( 'Baba', wp_html_excerpt( 'Baba &amp; Dyado', 8 ) );
    1527                $this->assertSame( 'Baba', wp_html_excerpt( 'Baba &#038; Dyado', 8 ) );
  • tests/phpunit/tests/formatting/HumanTimeDiff.php

     
    1010         * @group formatting
    1111         * @ticket 38773
    1212         * @dataProvider data_test_human_time_diff
     13         *
     14         * @covers ::human_time_diff
    1315         */
    1416        function test_human_time_diff( $expected, $stopdate, $message ) {
    1517                $startdate = new DateTime( '2016-01-01 12:00:00' );
  • tests/phpunit/tests/formatting/IsEmail.php

     
    44 * @group formatting
    55 */
    66class Tests_Formatting_IsEmail extends WP_UnitTestCase {
     7
     8        /**
     9         * @covers ::is_email
     10         */
    711        function test_returns_the_email_address_if_it_is_valid() {
    812                $data = array(
    913                        'bob@example.com',
     
    1721                }
    1822        }
    1923
     24        /**
     25         * @covers ::is_email
     26         */
    2027        function test_returns_false_if_given_an_invalid_email_address() {
    2128                $data = array(
    2229                        'khaaaaaaaaaaaaaaan!',
  • tests/phpunit/tests/formatting/isoDescrambler.php

     
    77        /*
    88         * Decodes text in RFC2047 "Q"-encoding, e.g.
    99         * =?iso-8859-1?q?this=20is=20some=20text?=
     10         *
     11         * @covers ::wp_iso_descrambler
    1012        */
    1113        function test_decodes_iso_8859_1_rfc2047_q_encoding() {
    1214                $this->assertSame( 'this is some text', wp_iso_descrambler( '=?iso-8859-1?q?this=20is=20some=20text?=' ) );
  • tests/phpunit/tests/formatting/JSEscape.php

     
    44 * @group formatting
    55 */
    66class Tests_Formatting_JSEscape extends WP_UnitTestCase {
     7
     8        /**
     9         * @covers ::esc_js
     10         */
    711        function test_js_escape_simple() {
    812                $out = esc_js( 'foo bar baz();' );
    913                $this->assertSame( 'foo bar baz();', $out );
    1014        }
    1115
     16        /**
     17         * @covers ::esc_js
     18         */
    1219        function test_js_escape_quotes() {
    1320                $out = esc_js( 'foo "bar" \'baz\'' );
    1421                // Does it make any sense to change " into &quot;?  Why not \"?
     
    1522                $this->assertSame( "foo &quot;bar&quot; \'baz\'", $out );
    1623        }
    1724
     25        /**
     26         * @covers ::esc_js
     27         */
    1828        function test_js_escape_backslash() {
    1929                $bs  = '\\';
    2030                $out = esc_js( 'foo ' . $bs . 't bar ' . $bs . $bs . ' baz' );
     
    2232                $this->assertSame( 'foo t bar ' . $bs . $bs . ' baz', $out );
    2333        }
    2434
     35        /**
     36         * @covers ::esc_js
     37         */
    2538        function test_js_escape_amp() {
    2639                $out = esc_js( 'foo & bar &baz; &nbsp;' );
    2740                $this->assertSame( 'foo &amp; bar &amp;baz; &nbsp;', $out );
    2841        }
    2942
     43        /**
     44         * @covers ::esc_js
     45         */
    3046        function test_js_escape_quote_entity() {
    3147                $out = esc_js( 'foo &#x27; bar &#39; baz &#x26;' );
    3248                $this->assertSame( "foo \\' bar \\' baz &#x26;", $out );
    3349        }
    3450
     51        /**
     52         * @covers ::esc_js
     53         */
    3554        function test_js_no_carriage_return() {
    3655                $out = esc_js( "foo\rbar\nbaz\r" );
    3756                // \r is stripped.
     
    3857                $this->assertSame( "foobar\\nbaz", $out );
    3958        }
    4059
     60        /**
     61         * @covers ::esc_js
     62         */
    4163        function test_js_escape_rn() {
    4264                $out = esc_js( "foo\r\nbar\nbaz\r\n" );
    4365                // \r is stripped.
  • tests/phpunit/tests/formatting/LikeEscape.php

     
    77        /**
    88         * @ticket 10041
    99         * @expectedDeprecated like_escape
     10         *
     11         * @covers ::like_escape
    1012         */
    1113        function test_like_escape() {
    1214
  • tests/phpunit/tests/formatting/LinksAddTarget.php

     
    9595         * Validate the normalize_whitespace function
    9696         *
    9797         * @dataProvider get_input_output
     98         *
     99         * @covers ::links_add_target
    98100         */
    99101        function test_normalize_whitespace( $content, $target, $tags, $exp_str ) {
    100102                if ( true === is_null( $target ) ) {
  • tests/phpunit/tests/formatting/MakeClickable.php

     
    44 * @group formatting
    55 */
    66class Tests_Formatting_MakeClickable extends WP_UnitTestCase {
     7
     8        /**
     9         * @covers ::make_clickable
     10         */
    711        function test_mailto_xss() {
    812                $in = 'testzzz@"STYLE="behavior:url(\'#default#time2\')"onBegin="alert(\'refresh-XSS\')"';
    913                $this->assertSame( $in, make_clickable( $in ) );
    1014        }
    1115
     16        /**
     17         * @covers ::make_clickable
     18         */
    1219        function test_valid_mailto() {
    1320                $valid_emails = array(
    1421                        'foo@example.com',
     
    2229                }
    2330        }
    2431
     32        /**
     33         * @covers ::make_clickable
     34         */
    2535        function test_invalid_mailto() {
    2636                $invalid_emails = array(
    2737                        'foo',
     
    3949        /**
    4050         * Tests that make_clickable() will not link trailing periods, commas,
    4151         * and (semi-)colons in URLs with protocol (i.e. http://wordpress.org).
     52         *
     53         * @covers ::make_clickable
    4254         */
    4355        function test_strip_trailing_with_protocol() {
    4456                $urls_before   = array(
     
    6678        /**
    6779         * Tests that make_clickable() will not link trailing periods, commas,
    6880         * and (semi-)colons in URLs with protocol (i.e. http://wordpress.org).
     81         *
     82         * @covers ::make_clickable
    6983         */
    7084        function test_strip_trailing_with_protocol_nothing_afterwards() {
    7185                $urls_before   = array(
     
    95109        /**
    96110         * Tests that make_clickable() will not link trailing periods, commas,
    97111         * and (semi-)colons in URLs without protocol (i.e. www.wordpress.org).
     112         *
     113         * @covers ::make_clickable
    98114         */
    99115        function test_strip_trailing_without_protocol() {
    100116                $urls_before   = array(
     
    122138        /**
    123139         * Tests that make_clickable() will not link trailing periods, commas,
    124140         * and (semi-)colons in URLs without protocol (i.e. www.wordpress.org).
     141         *
     142         * @covers ::make_clickable
    125143         */
    126144        function test_strip_trailing_without_protocol_nothing_afterwards() {
    127145                $urls_before   = array(
     
    148166
    149167        /**
    150168         * @ticket 4570
     169         *
     170         * @covers ::make_clickable
    151171         */
    152172        function test_iri() {
    153173                $urls_before   = array(
     
    167187
    168188        /**
    169189         * @ticket 10990
     190         *
     191         * @covers ::make_clickable
    170192         */
    171193        function test_brackets_in_urls() {
    172194                $urls_before   = array(
     
    206228         * Based on real comments which were incorrectly linked.
    207229         *
    208230         * @ticket 11211
     231         *
     232         * @covers ::make_clickable
    209233         */
    210234        function test_real_world_examples() {
    211235                $urls_before   = array(
     
    227251
    228252        /**
    229253         * @ticket 14993
     254         *
     255         * @covers ::make_clickable
    230256         */
    231257        function test_twitter_hash_bang() {
    232258                $urls_before   = array(
     
    244270                }
    245271        }
    246272
     273        /**
     274         * @covers ::make_clickable
     275         */
    247276        function test_wrapped_in_angles() {
    248277                $before   = array(
    249278                        'URL wrapped in angle brackets <http://example.com/>',
     
    260289                }
    261290        }
    262291
     292        /**
     293         * @covers ::make_clickable
     294         */
    263295        function test_preceded_by_punctuation() {
    264296                $before   = array(
    265297                        'Comma then URL,http://example.com/',
     
    282314                }
    283315        }
    284316
     317        /**
     318         * @covers ::make_clickable
     319         */
    285320        function test_dont_break_attributes() {
    286321                $urls_before   = array(
    287322                        "<img src='http://trunk.domain/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley'>",
     
    308343
    309344        /**
    310345         * @ticket 23756
     346         *
     347         * @covers ::make_clickable
    311348         */
    312349        function test_no_links_inside_pre_or_code() {
    313350                $before = array(
     
    349386
    350387        /**
    351388         * @ticket 16892
     389         *
     390         * @covers ::make_clickable
    352391         */
    353392        function test_click_inside_html() {
    354393                $urls_before   = array(
     
    364403                }
    365404        }
    366405
     406        /**
     407         * @covers ::make_clickable
     408         */
    367409        function test_no_links_within_links() {
    368410                $in = array(
    369411                        'Some text with a link <a href="http://example.com">http://example.com</a>',
     
    376418
    377419        /**
    378420         * @ticket 16892
     421         *
     422         * @covers ::make_clickable
    379423         */
    380424        function test_no_segfault() {
    381425                $in  = str_repeat( 'http://example.com/2011/03/18/post-title/', 256 );
     
    385429
    386430        /**
    387431         * @ticket 19028
     432         *
     433         * @covers ::make_clickable
    388434         */
    389435        function test_line_break_in_existing_clickable_link() {
    390436                $html = "<a
     
    395441        /**
    396442         * @ticket 30162
    397443         * @dataProvider data_script_and_style_tags
     444         *
     445         * @covers ::make_clickable
    398446         */
    399447        public function test_dont_link_script_and_style_tags( $tag ) {
    400448                $this->assertSame( $tag, make_clickable( $tag ) );
     
    420468        /**
    421469         * @ticket 48022
    422470         * @dataProvider data_add_rel_ugc_in_comments
     471         *
     472         * @covers ::make_clickable
    423473         */
    424474        public function test_add_rel_ugc_in_comments( $content, $expected ) {
    425475                $comment_id = self::factory()->comment->create(
  • tests/phpunit/tests/formatting/MapDeep.php

     
    66 */
    77class Tests_Formatting_MapDeep extends WP_UnitTestCase {
    88
     9        /**
     10         * @covers ::map_deep
     11         */
    912        public function test_map_deep_with_any_function_over_empty_array_should_return_empty_array() {
    1013                $this->assertSame( array(), map_deep( array(), array( $this, 'append_baba' ) ) );
    1114        }
    1215
     16        /**
     17         * @covers ::map_deep
     18         */
    1319        public function test_map_deep_should_map_each_element_of_array_one_level_deep() {
    1420                $this->assertSame(
    1521                        array(
     
    2632                );
    2733        }
    2834
     35        /**
     36         * @covers ::map_deep
     37         */
    2938        public function test_map_deep_should_map_each_element_of_array_two_levels_deep() {
    3039                $this->assertSame(
    3140                        array(
     
    4655                );
    4756        }
    4857
     58        /**
     59         * @covers ::map_deep
     60         */
    4961        public function test_map_deep_should_map_each_object_element_of_an_array() {
    5062                $this->assertEquals(
    5163                        array(
     
    6678                );
    6779        }
    6880
     81        /**
     82         * @covers ::map_deep
     83         */
    6984        public function test_map_deep_should_apply_the_function_to_a_string() {
    7085                $this->assertSame( 'xbaba', map_deep( 'x', array( $this, 'append_baba' ) ) );
    7186        }
    7287
     88        /**
     89         * @covers ::map_deep
     90         */
    7391        public function test_map_deep_should_apply_the_function_to_an_integer() {
    7492                $this->assertSame( '5baba', map_deep( 5, array( $this, 'append_baba' ) ) );
    7593        }
    7694
     95        /**
     96         * @covers ::map_deep
     97         */
    7798        public function test_map_deep_should_map_each_property_of_an_object() {
    7899                $this->assertEquals(
    79100                        (object) array(
     
    90111                );
    91112        }
    92113
     114        /**
     115         * @covers ::map_deep
     116         */
    93117        public function test_map_deep_should_map_each_array_property_of_an_object() {
    94118                $this->assertEquals(
    95119                        (object) array(
     
    110134                );
    111135        }
    112136
     137        /**
     138         * @covers ::map_deep
     139         */
    113140        public function test_map_deep_should_map_each_object_property_of_an_object() {
    114141                $this->assertEquals(
    115142                        (object) array(
     
    132159
    133160        /**
    134161         * @ticket 35058
     162         *
     163         * @covers ::map_deep
    135164         */
    136165        public function test_map_deep_should_map_object_properties_passed_by_reference() {
    137166                $object_a = (object) array( 'var0' => 'a' );
     
    150179
    151180        /**
    152181         * @ticket 35058
     182         *
     183         * @covers ::map_deep
    153184         */
    154185        public function test_map_deep_should_map_array_elements_passed_by_reference() {
    155186                $array_a = array( 'var0' => 'a' );
  • tests/phpunit/tests/formatting/NormalizeWhitespace.php

     
    4545         * Validate the normalize_whitespace function
    4646         *
    4747         * @dataProvider get_input_output
     48         *
     49         * @covers ::normalize_whitespace
    4850         */
    4951        function test_normalize_whitespace( $in_str, $exp_str ) {
    5052                $this->assertSame( $exp_str, normalize_whitespace( $in_str ) );
  • tests/phpunit/tests/formatting/redirect.php

     
    66 * @group redirect
    77 */
    88class Tests_Formatting_Redirect extends WP_UnitTestCase {
     9
    910        function setUp() {
    1011                parent::setUp();
    1112                add_filter( 'home_url', array( $this, 'home_url' ) );
     
    2728         *
    2829         * @param string $location The path or URL to redirect to.
    2930         * @param int    $status   HTTP response status code to use.
     31         *
     32         * @covers ::wp_redirect
    3033         */
    3134        public function test_wp_redirect_bad_status_code( $location, $status ) {
    3235                $this->expectException( 'WPDieException' );
     
    4649                );
    4750        }
    4851
     52        /**
     53         * @covers ::wp_sanitize_redirect
     54         */
    4955        function test_wp_sanitize_redirect() {
    5056                $this->assertSame( 'http://example.com/watchthelinefeedgo', wp_sanitize_redirect( 'http://example.com/watchthelinefeed%0Ago' ) );
    5157                $this->assertSame( 'http://example.com/watchthelinefeedgo', wp_sanitize_redirect( 'http://example.com/watchthelinefeed%0ago' ) );
     
    6470
    6571        /**
    6672         * @group 36998
     73         *
     74         * @covers ::wp_sanitize_redirect
    6775         */
    6876        function test_wp_sanitize_redirect_should_encode_spaces() {
    6977                $this->assertSame( 'http://example.com/test%20spaces', wp_sanitize_redirect( 'http://example.com/test%20spaces' ) );
     
    7280
    7381        /**
    7482         * @dataProvider valid_url_provider
     83         *
     84         * @covers ::wp_validate_redirect
    7585         */
    7686        function test_wp_validate_redirect_valid_url( $url, $expected ) {
    7787                $this->assertSame( $expected, wp_validate_redirect( $url ) );
     
    7989
    8090        /**
    8191         * @dataProvider invalid_url_provider
     92         *
     93         * @covers ::wp_validate_redirect
    8294         */
    8395        function test_wp_validate_redirect_invalid_url( $url ) {
    8496                $this->assertEquals( false, wp_validate_redirect( $url, false ) );
     
    171183        /**
    172184         * @ticket 47980
    173185         * @dataProvider relative_url_provider
     186         *
     187         * @covers ::wp_validate_redirect
    174188         */
    175189        function test_wp_validate_redirect_relative_url( $current_uri, $url, $expected ) {
    176190                // Backup the global.
  • tests/phpunit/tests/formatting/RemoveAccents.php

     
    44 * @group formatting
    55 */
    66class Tests_Formatting_RemoveAccents extends WP_UnitTestCase {
     7
     8        /**
     9         * @covers ::remove_accents
     10         */
    711        public function test_remove_accents_simple() {
    812                $this->assertSame( 'abcdefghijkl', remove_accents( 'abcdefghijkl' ) );
    913        }
     
    1014
    1115        /**
    1216         * @ticket 9591
     17         *
     18         * @covers ::remove_accents
    1319         */
    1420        public function test_remove_accents_latin1_supplement() {
    1521                $input  = 'ªºÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ';
     
    1824                $this->assertSame( $output, remove_accents( $input ), 'remove_accents replaces Latin-1 Supplement' );
    1925        }
    2026
     27        /**
     28         * @covers ::remove_accents
     29         */
    2130        public function test_remove_accents_latin_extended_a() {
    2231                $input  = 'ĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſ';
    2332                $output = 'AaAaAaCcCcCcCcDdDdEeEeEeEeEeGgGgGgGgHhHhIiIiIiIiIiIJijJjKkkLlLlLlLlLlNnNnNnnNnOoOoOoOEoeRrRrRrSsSsSsSsTtTtTtUuUuUuUuUuUuWwYyYZzZzZzs';
     
    2534                $this->assertSame( $output, remove_accents( $input ), 'remove_accents replaces Latin Extended A' );
    2635        }
    2736
     37        /**
     38         * @covers ::remove_accents
     39         */
    2840        public function test_remove_accents_latin_extended_b() {
    2941                $this->assertSame( 'SsTt', remove_accents( 'ȘșȚț' ), 'remove_accents replaces Latin Extended B' );
    3042        }
    3143
     44        /**
     45         * @covers ::remove_accents
     46         */
    3247        public function test_remove_accents_euro_pound_signs() {
    3348                $this->assertSame( 'E', remove_accents( '€' ), 'remove_accents replaces euro sign' );
    3449                $this->assertSame( '', remove_accents( '£' ), 'remove_accents replaces pound sign' );
    3550        }
    3651
     52        /**
     53         * @covers ::remove_accents
     54         */
    3755        public function test_remove_accents_iso8859() {
    3856                // File is Latin1-encoded.
    3957                $file   = DIR_TESTDATA . '/formatting/remove_accents.01.input.txt';
     
    4664
    4765        /**
    4866         * @ticket 17738
     67         *
     68         * @covers ::remove_accents
    4969         */
    5070        public function test_remove_accents_vowels_diacritic() {
    5171                // Vowels with diacritic.
     
    6585
    6686        /**
    6787         * @ticket 20772
     88         *
     89         * @covers ::remove_accents
    6890         */
    6991        public function test_remove_accents_hanyu_pinyin() {
    7092                // Vowels with diacritic (Chinese, Hanyu Pinyin).
     
    86108
    87109        /**
    88110         * @ticket 3782
     111         *
     112         * @covers ::remove_accents
    89113         */
    90114        public function test_remove_accents_germanic_umlauts() {
    91115                add_filter( 'locale', array( $this, '_remove_accents_germanic_umlauts_cb' ) );
     
    101125
    102126        /**
    103127         * @ticket 23907
     128         *
     129         * @covers ::remove_accents
    104130         */
    105131        public function test_remove_danish_accents() {
    106132                add_filter( 'locale', array( $this, '_set_locale_to_danish' ) );
     
    116142
    117143        /**
    118144         * @ticket 37086
     145         *
     146         * @covers ::remove_accents
    119147         */
    120148        public function test_remove_catalan_middot() {
    121149                add_filter( 'locale', array( $this, '_set_locale_to_catalan' ) );
     
    133161
    134162        /**
    135163         * @ticket 38078
     164         *
     165         * @covers ::remove_accents
    136166         */
    137167        public function test_transcribe_serbian_crossed_d() {
    138168                add_filter( 'locale', array( $this, '_set_locale_to_serbian' ) );
  • tests/phpunit/tests/formatting/SanitizeFileName.php

     
    44 * @group formatting
    55 */
    66class Tests_Formatting_SanitizeFileName extends WP_UnitTestCase {
     7
     8        /**
     9         * @covers ::sanitize_file_name
     10         */
    711        function test_munges_extensions() {
    812                # r17990
    913                $file_name = sanitize_file_name( 'test.phtml.txt' );
     
    1014                $this->assertSame( 'test.phtml_.txt', $file_name );
    1115        }
    1216
     17        /**
     18         * @covers ::sanitize_file_name
     19         */
    1320        function test_removes_special_chars() {
    1421                $special_chars = array( '?', '[', ']', '/', '\\', '=', '<', '>', ':', ';', ',', "'", '"', '&', '$', '#', '*', '(', ')', '|', '~', '`', '!', '{', '}', '%', '+', '’', '«', '»', '”', '“', chr( 0 ) );
    1522                $string        = 'test';
     
    2229
    2330        /**
    2431         * @ticket 22363
     32         *
     33         * @covers ::sanitize_file_name
    2534         */
    2635        function test_removes_accents() {
    2736                $in  = 'àáâãäåæçèéêëìíîïñòóôõöøùúûüýÿ';
     
    3342         * Test that spaces are correctly replaced with dashes.
    3443         *
    3544         * @ticket 16330
     45         *
     46         * @covers ::sanitize_file_name
    3647         */
    3748        function test_replaces_spaces() {
    3849                $urls = array(
     
    4758                }
    4859        }
    4960
     61        /**
     62         * @covers ::sanitize_file_name
     63         */
    5064        function test_replaces_any_number_of_hyphens_with_one_hyphen() {
    5165                $this->assertSame( 'a-t-t', sanitize_file_name( 'a----t----t' ) );
    5266        }
    5367
     68        /**
     69         * @covers ::sanitize_file_name
     70         */
    5471        function test_trims_trailing_hyphens() {
    5572                $this->assertSame( 'a-t-t', sanitize_file_name( 'a----t----t----' ) );
    5673        }
    5774
     75        /**
     76         * @covers ::sanitize_file_name
     77         */
    5878        function test_replaces_any_amount_of_whitespace_with_one_hyphen() {
    5979                $this->assertSame( 'a-t', sanitize_file_name( 'a          t' ) );
    6080                $this->assertSame( 'a-t', sanitize_file_name( "a    \n\n\nt" ) );
     
    6282
    6383        /**
    6484         * @ticket 16226
     85         *
     86         * @covers ::sanitize_file_name
    6587         */
    6688        function test_replaces_percent_sign() {
    6789                $this->assertSame( 'a22b.jpg', sanitize_file_name( 'a%22b.jpg' ) );
    6890        }
    6991
     92        /**
     93         * @covers ::sanitize_file_name
     94         */
    7095        function test_replaces_unnamed_file_extensions() {
    7196                // Test filenames with both supported and unsupported extensions.
    7297                $this->assertSame( 'unnamed-file.exe', sanitize_file_name( '_.exe' ) );
     
    7398                $this->assertSame( 'unnamed-file.jpg', sanitize_file_name( '_.jpg' ) );
    7499        }
    75100
     101        /**
     102         * @covers ::sanitize_file_name
     103         */
    76104        function test_replaces_unnamed_file_extensionless() {
    77105                // Test a filenames that becomes extensionless.
    78106                $this->assertSame( 'no-extension', sanitize_file_name( '_.no-extension' ) );
     
    80108
    81109        /**
    82110         * @dataProvider data_wp_filenames
     111         *
     112         * @covers ::sanitize_file_name
    83113         */
    84114        function test_replaces_invalid_utf8_characters( $input, $expected ) {
    85115                $this->assertSame( $expected, sanitize_file_name( $input ) );
  • tests/phpunit/tests/formatting/SanitizeMimeType.php

     
    77
    88        /**
    99         * @ticket 17855
     10         *
     11         * @covers ::sanitize_mime_type
    1012         */
    1113        function test_sanitize_valid_mime_type() {
    1214                $inputs = array(
  • tests/phpunit/tests/formatting/SanitizeOrderby.php

     
    88        /**
    99         * @covers ::sanitize_sql_orderby
    1010         * @dataProvider valid_orderbys
     11         *
     12         * @covers ::sanitize_sql_orderby
    1113         */
    1214        function test_valid( $orderby ) {
    1315                $this->assertSame( $orderby, sanitize_sql_orderby( $orderby ) );
     
    3537        /**
    3638         * @covers ::sanitize_sql_orderby
    3739         * @dataProvider invalid_orderbys
     40         *
     41         * @covers ::sanitize_sql_orderby
    3842         */
    3943        function test_invalid( $orderby ) {
    4044                $this->assertFalse( sanitize_sql_orderby( $orderby ) );
  • tests/phpunit/tests/formatting/SanitizeTextField.php

     
    127127        /**
    128128         * @ticket 32257
    129129         * @dataProvider data_sanitize_text_field
     130         *
     131         * @covers ::sanitize_text_field
     132         * @covers ::sanitize_textarea_field
    130133         */
    131134        function test_sanitize_text_field( $string, $expected ) {
    132135                if ( is_array( $expected ) ) {
  • tests/phpunit/tests/formatting/SanitizeTitle.php

     
    44 * @group formatting
    55 */
    66class Tests_Formatting_SanitizeTitle extends WP_UnitTestCase {
     7
     8        /**
     9         * @covers ::sanitize_title
     10         */
    711        function test_strips_html() {
    812                $input    = 'Captain <strong>Awesome</strong>';
    913                $expected = 'captain-awesome';
     
    1014                $this->assertSame( $expected, sanitize_title( $input ) );
    1115        }
    1216
     17        /**
     18         * @covers ::sanitize_title
     19         */
    1320        function test_titles_sanitized_to_nothing_are_replaced_with_optional_fallback() {
    1421                $input    = '<strong></strong>';
    1522                $fallback = 'Captain Awesome';
  • tests/phpunit/tests/formatting/SanitizeTitleWithDashes.php

     
    44 * @group formatting
    55 */
    66class Tests_Formatting_SanitizeTitleWithDashes extends WP_UnitTestCase {
     7        /**
     8         * @covers ::sanitize_title_with_dashes
     9         */
    710        function test_strips_html() {
    811                $input    = 'Captain <strong>Awesome</strong>';
    912                $expected = 'captain-awesome';
    10                 $this->assertSame( $expected, sanitize_title( $input ) );
     13                $this->assertSame( $expected, sanitize_title_with_dashes( $input ) );
    1114        }
    1215
     16        /**
     17         * @covers ::sanitize_title_with_dashes
     18         */
    1319        function test_strips_unencoded_percent_signs() {
    1420                $this->assertSame( 'fran%c3%a7ois', sanitize_title_with_dashes( 'fran%c3%a7%ois' ) );
    1521        }
    1622
     23        /**
     24         * @covers ::sanitize_title_with_dashes
     25         */
    1726        function test_makes_title_lowercase() {
    1827                $this->assertSame( 'abc', sanitize_title_with_dashes( 'ABC' ) );
    1928        }
    2029
     30        /**
     31         * @covers ::sanitize_title_with_dashes
     32         */
    2133        function test_replaces_any_amount_of_whitespace_with_one_hyphen() {
    2234                $this->assertSame( 'a-t', sanitize_title_with_dashes( 'a          t' ) );
    2335                $this->assertSame( 'a-t', sanitize_title_with_dashes( "a    \n\n\nt" ) );
    2436        }
    2537
     38        /**
     39         * @covers ::sanitize_title_with_dashes
     40         */
    2641        function test_replaces_any_number_of_hyphens_with_one_hyphen() {
    2742                $this->assertSame( 'a-t-t', sanitize_title_with_dashes( 'a----t----t' ) );
    2843        }
    2944
     45        /**
     46         * @covers ::sanitize_title_with_dashes
     47         */
    3048        function test_trims_trailing_hyphens() {
    3149                $this->assertSame( 'a-t-t', sanitize_title_with_dashes( 'a----t----t----' ) );
    3250        }
    3351
     52        /**
     53         * @covers ::sanitize_title_with_dashes
     54         */
    3455        function test_handles_non_entity_ampersands() {
    3556                $this->assertSame( 'penn-teller-bull', sanitize_title_with_dashes( 'penn & teller bull' ) );
    3657        }
    3758
     59        /**
     60         * @covers ::sanitize_title_with_dashes
     61         */
    3862        public function test_strips_nbsp_ndash_and_amp() {
    3963                $this->assertSame( 'no-entities-here', sanitize_title_with_dashes( 'No &nbsp; Entities &ndash; Here &amp;' ) );
    4064        }
    4165
     66        /**
     67         * @covers ::sanitize_title_with_dashes
     68         */
    4269        public function test_strips_encoded_ampersand() {
    4370                $this->assertSame( 'one-two', sanitize_title_with_dashes( 'One &amp; Two', '', 'save' ) );
    4471        }
    4572
     73        /**
     74         * @covers ::sanitize_title_with_dashes
     75         */
    4676        public function test_strips_url_encoded_ampersand() {
    4777                $this->assertSame( 'one-two', sanitize_title_with_dashes( 'One &#123; Two;', '', 'save' ) );
    4878        }
    4979
     80        /**
     81         * @covers ::sanitize_title_with_dashes
     82         */
    5083        public function test_strips_trademark_symbol() {
    5184                $this->assertSame( 'one-two', sanitize_title_with_dashes( 'One Two™;', '', 'save' ) );
    5285        }
    5386
     87        /**
     88         * @covers ::sanitize_title_with_dashes
     89         */
    5490        public function test_strips_unencoded_ampersand_followed_by_encoded_ampersand() {
    5591                $this->assertSame( 'one-two', sanitize_title_with_dashes( 'One &&amp; Two;', '', 'save' ) );
    5692        }
    5793
     94        /**
     95         * @covers ::sanitize_title_with_dashes
     96         */
    5897        public function test_strips_unencoded_ampersand_when_not_surrounded_by_spaces() {
    5998                $this->assertSame( 'onetwo', sanitize_title_with_dashes( 'One&Two', '', 'save' ) );
    6099        }
     
    65104
    66105        /**
    67106         * @ticket 31790
     107         *
     108         * @covers ::sanitize_title_with_dashes
    68109         */
    69110        function test_replaces_nbsp_entities() {
    70111                $this->assertSame( 'dont-break-the-space', sanitize_title_with_dashes( "don't&nbsp;break&#160;the&nbsp;space", '', 'save' ) );
    71112        }
    72113
     114        /**
     115         * @covers ::sanitize_title_with_dashes
     116         */
    73117        function test_replaces_ndash_mdash() {
    74118                $this->assertSame( 'do-the-dash', sanitize_title_with_dashes( 'Do – the Dash', '', 'save' ) );
    75119                $this->assertSame( 'do-the-dash', sanitize_title_with_dashes( 'Do the — Dash', '', 'save' ) );
     
    77121
    78122        /**
    79123         * @ticket 31790
     124         *
     125         * @covers ::sanitize_title_with_dashes
    80126         */
    81127        function test_replaces_ndash_mdash_entities() {
    82128                $this->assertSame( 'do-the-dash', sanitize_title_with_dashes( 'Do &ndash; the &#8211; Dash', '', 'save' ) );
     
    83129                $this->assertSame( 'do-the-dash', sanitize_title_with_dashes( 'Do &mdash; the &#8212; Dash', '', 'save' ) );
    84130        }
    85131
     132        /**
     133         * @covers ::sanitize_title_with_dashes
     134         */
    86135        function test_replaces_iexcel_iquest() {
    87136                $this->assertSame( 'just-a-slug', sanitize_title_with_dashes( 'Just ¡a Slug', '', 'save' ) );
    88137                $this->assertSame( 'just-a-slug', sanitize_title_with_dashes( 'Just a Slug¿', '', 'save' ) );
    89138        }
    90139
     140        /**
     141         * @covers ::sanitize_title_with_dashes
     142         */
    91143        function test_replaces_angle_quotes() {
    92144                $this->assertSame( 'just-a-slug', sanitize_title_with_dashes( '‹Just a Slug›', '', 'save' ) );
    93145                $this->assertSame( 'just-a-slug', sanitize_title_with_dashes( '«Just a Slug»', '', 'save' ) );
    94146        }
    95147
     148        /**
     149         * @covers ::sanitize_title_with_dashes
     150         */
    96151        function test_replaces_curly_quotes() {
    97152                $this->assertSame( 'hey-its-curly-joe', sanitize_title_with_dashes( 'Hey its “Curly Joe”', '', 'save' ) );
    98153                $this->assertSame( 'hey-its-curly-joe', sanitize_title_with_dashes( 'Hey its ‘Curly Joe’', '', 'save' ) );
     
    103158
    104159        /**
    105160         * @ticket 49791
     161         *
     162         * @covers ::sanitize_title_with_dashes
    106163         */
    107164        function test_replaces_bullet() {
    108165                $this->assertSame( 'fancy-title-amazing', sanitize_title_with_dashes( 'Fancy Title • Amazing', '', 'save' ) );
    109166        }
    110 
     167        /**
     168         * @covers ::sanitize_title_with_dashes
     169         */
    111170        function test_replaces_copy_reg_deg_trade() {
    112171                $this->assertSame( 'just-a-slug', sanitize_title_with_dashes( 'Just © a Slug', '', 'save' ) );
    113172                $this->assertSame( 'just-a-slug', sanitize_title_with_dashes( '® Just a Slug', '', 'save' ) );
     
    117176
    118177        /**
    119178         * @ticket 10792
     179         *
     180         * @covers ::sanitize_title_with_dashes
    120181         */
    121182        function test_replaces_forward_slash() {
    122183                $this->assertSame( 'songs-by-lennon-mccartney', sanitize_title_with_dashes( 'songs by Lennon/McCartney', '', 'save' ) );
     
    128189
    129190        /**
    130191         * @ticket 19820
     192         *
     193         * @covers ::sanitize_title_with_dashes
    131194         */
    132195        function test_replaces_multiply_sign() {
    133196                $this->assertSame( '6x7-is-42', sanitize_title_with_dashes( '6×7 is 42', '', 'save' ) );
     
    135198
    136199        /**
    137200         * @ticket 20772
     201         *
     202         * @covers ::sanitize_title_with_dashes
    138203         */
    139204        function test_replaces_standalone_diacritic() {
    140205                $this->assertSame( 'aaaa', sanitize_title_with_dashes( 'āáǎà', '', 'save' ) );
     
    142207
    143208        /**
    144209         * @ticket 22395
     210         *
     211         * @covers ::sanitize_title_with_dashes
    145212         */
    146213        function test_replaces_acute_accents() {
    147214                $this->assertSame( 'aaaa', sanitize_title_with_dashes( 'ááa´aˊ', '', 'save' ) );
  • tests/phpunit/tests/formatting/SanitizeTrackbackUrls.php

     
    77        /**
    88         * @ticket 21624
    99         * @dataProvider breaks
     10         *
     11         * @covers ::sanitize_trackback_urls
    1012         */
    1113        function test_sanitize_trackback_urls_with_multiple_urls( $break ) {
    1214                $this->assertSame( "http://example.com\nhttp://example.org", sanitize_trackback_urls( "http://example.com{$break}http://example.org" ) );
  • tests/phpunit/tests/formatting/SanitizeUser.php

     
    44 * @group formatting
    55 */
    66class Tests_Formatting_SanitizeUser extends WP_UnitTestCase {
     7
     8        /**
     9         * @covers ::sanitize_user
     10         */
    711        function test_strips_html() {
    812                $input    = 'Captain <strong>Awesome</strong>';
    913                $expected = is_multisite() ? 'captain awesome' : 'Captain Awesome';
     
    1014                $this->assertSame( $expected, sanitize_user( $input ) );
    1115        }
    1216
     17        /**
     18         * @covers ::sanitize_user
     19         */
    1320        public function test_strips_encoded_ampersand() {
    1421                $expected = 'ATT';
    1522
     
    2128                $this->assertSame( $expected, sanitize_user( 'AT&amp;T' ) );
    2229        }
    2330
     31        /**
     32         * @covers ::sanitize_user
     33         */
    2434        public function test_strips_encoded_ampersand_when_followed_by_semicolon() {
    2535                $expected = 'ATT Test;';
    2636
     
    3242                $this->assertSame( $expected, sanitize_user( 'AT&amp;T Test;' ) );
    3343        }
    3444
     45        /**
     46         * @covers ::sanitize_user
     47         */
    3548        function test_strips_percent_encoded_octets() {
    3649                $expected = is_multisite() ? 'franois' : 'Franois';
    3750                $this->assertSame( $expected, sanitize_user( 'Fran%c3%a7ois' ) );
    3851        }
     52
     53        /**
     54         * @covers ::sanitize_user
     55         */
    3956        function test_optional_strict_mode_reduces_to_safe_ascii_subset() {
    4057                $this->assertSame( 'abc', sanitize_user( '()~ab~ˆcˆ!', true ) );
    4158        }
  • tests/phpunit/tests/formatting/SeemsUtf8.php

     
    99         * `seems_utf8` returns true for utf-8 strings, false otherwise.
    1010         *
    1111         * @dataProvider utf8_strings
     12         *
     13         * @covers ::seems_utf8
    1214         */
    1315        function test_returns_true_for_utf8_strings( $utf8_string ) {
    1416                // From http://www.i18nguy.com/unicode-example.html
     
    2628
    2729        /**
    2830         * @dataProvider big5_strings
     31         *
     32         * @covers ::seems_utf8
    2933         */
    3034        function test_returns_false_for_non_utf8_strings( $big5_string ) {
    3135                $this->assertFalse( seems_utf8( $big5_string ) );
  • tests/phpunit/tests/formatting/Slashit.php

     
    44 * @group formatting
    55 */
    66class Tests_Formatting_Slashit extends WP_UnitTestCase {
     7
     8        /**
     9         * @covers ::backslashit
     10         */
    711        function test_backslashes_middle_numbers() {
    812                $this->assertSame( "\\a-!9\\a943\\b\\c", backslashit( 'a-!9a943bc' ) );
    913        }
    1014
     15        /**
     16         * @covers ::backslashit
     17         */
    1118        function test_backslashes_alphas() {
    1219                $this->assertSame( "\\a943\\b\\c", backslashit( 'a943bc' ) );
    1320        }
    1421
     22        /**
     23         * @covers ::backslashit
     24         */
    1525        function test_double_backslashes_leading_numbers() {
    1626                $this->assertSame( '\\\\95', backslashit( '95' ) );
    1727        }
    1828
     29        /**
     30         * @covers ::untrailingslashit
     31         */
    1932        function test_removes_trailing_slashes() {
    2033                $this->assertSame( 'a', untrailingslashit( 'a/' ) );
    2134                $this->assertSame( 'a', untrailingslashit( 'a////' ) );
     
    2336
    2437        /**
    2538         * @ticket 22267
     39         *
     40         * @covers ::untrailingslashit
    2641         */
    2742        function test_removes_trailing_backslashes() {
    2843                $this->assertSame( 'a', untrailingslashit( 'a\\' ) );
     
    3146
    3247        /**
    3348         * @ticket 22267
     49         *
     50         * @covers ::untrailingslashit
    3451         */
    3552        function test_removes_trailing_mixed_slashes() {
    3653                $this->assertSame( 'a', untrailingslashit( 'a/\\' ) );
     
    3754                $this->assertSame( 'a', untrailingslashit( 'a\\/\\///\\\\//' ) );
    3855        }
    3956
     57        /**
     58         * @covers ::trailingslashit
     59         */
    4060        function test_adds_trailing_slash() {
    4161                $this->assertSame( 'a/', trailingslashit( 'a' ) );
    4262        }
    4363
     64        /**
     65         * @covers ::trailingslashit
     66         */
    4467        function test_does_not_add_trailing_slash_if_one_exists() {
    4568                $this->assertSame( 'a/', trailingslashit( 'a/' ) );
    4669        }
     
    4770
    4871        /**
    4972         * @ticket 22267
     73         *
     74         * @covers ::trailingslashit
    5075         */
    5176        function test_converts_trailing_backslash_to_slash_if_one_exists() {
    5277                $this->assertSame( 'a/', trailingslashit( 'a\\' ) );
  • tests/phpunit/tests/formatting/Smilies.php

     
    4747         *
    4848         * Basic Validation Test to confirm that smilies are converted to image
    4949         * when use_smilies = 1 and not when use_smilies = 0
     50         *
     51         * @covers ::convert_smilies
    5052         */
    5153        function test_convert_standard_smilies( $in_txt, $converted_txt ) {
    5254                // Standard smilies, use_smilies: ON.
     
    9092         * @dataProvider get_custom_smilies_input_output
    9193         *
    9294         * Validate Custom Smilies are converted to images when use_smilies = 1
     95         *
     96         * @covers ::convert_smilies
    9397         */
    9498        function test_convert_custom_smilies( $in_txt, $converted_txt ) {
    9599                global $wpsmiliestrans;
     
    142146         *
    143147         * @ticket 16448
    144148         * @dataProvider get_smilies_ignore_tags
     149         *
     150         * @covers ::convert_smilies
    145151         */
    146152        public function test_ignore_smilies_in_tags( $element ) {
    147153                $includes_path = includes_url( 'images/smilies/' );
     
    199205         *
    200206         * @ticket 20124
    201207         * @dataProvider get_smilies_combinations
     208         *
     209         * @covers ::convert_smilies
    202210         */
    203211        public function test_smilies_combinations( $in_txt, $converted_txt ) {
    204212                // Custom smilies, use_smilies: ON.
     
    241249         *
    242250         * @ticket 25303
    243251         * @dataProvider get_single_smilies_input_output
     252         *
     253         * @covers ::convert_smilies
    244254         */
    245255        public function test_single_smilies_in_wpsmiliestrans( $in_txt, $converted_txt ) {
    246256                global $wpsmiliestrans;
     
    298308         *
    299309         * @ticket 22692
    300310         * @dataProvider get_spaces_around_smilies
     311         *
     312         * @covers ::convert_smilies
    301313         */
    302314        function test_spaces_around_smilies( $in_txt, $converted_txt ) {
    303315                // Standard smilies, use_smilies: ON.
     
    315327         * Test to ensure smilies can be removed with a filter
    316328         *
    317329         * @ticket 35905
     330         *
     331         * @covers ::convert_smilies
    318332         */
    319333        public function test_smilies_filter_removes_smilies() {
    320334                add_filter( 'smilies', array( $this, '_filter_remove_smilies' ) );
     
    330344         * Test to ensure smilies can be added with a filter
    331345         *
    332346         * @ticket 35905
     347         *
     348         * @covers ::convert_smilies
    333349         */
    334350        public function test_smilies_filter_adds_smilies() {
    335351                add_filter( 'smilies', array( $this, '_filter_add_smilies' ) );
  • tests/phpunit/tests/formatting/StripSlashesDeep.php

     
    77class Tests_Formatting_StripSlashesDeep extends WP_UnitTestCase {
    88        /**
    99         * @ticket 18026
     10         *
     11         * @covers ::stripslashes_deep
    1012         */
    1113        function test_preserves_original_datatype() {
    1214
     
    3133                $this->assertSame( $obj, stripslashes_deep( $obj ) );
    3234        }
    3335
     36        /**
     37         * @covers ::stripslashes_deep
     38         */
    3439        function test_strips_slashes() {
    3540                $old = "I can\'t see, isn\'t that it?";
    3641                $new = "I can't see, isn't that it?";
     
    4651                $this->assertEquals( $obj_new, stripslashes_deep( $obj_old ) );
    4752        }
    4853
     54        /**
     55         * @covers ::stripslashes_deep
     56         */
    4957        function test_permits_escaped_slash() {
    5058                $txt = "I can't see, isn\'t that it?";
    5159                $this->assertSame( $txt, stripslashes_deep( "I can\'t see, isn\\\'t that it?" ) );
  • tests/phpunit/tests/formatting/UrlencodeDeep.php

     
    2626         *
    2727         * @param string $actual
    2828         * @param string $expected
     29         *
     30         * @covers ::urlencode_deep
    2931         */
    3032        public function test_urlencode_deep_should_encode_individual_value( $actual, $expected ) {
    3133                $this->assertSame( $expected, urlencode_deep( $actual ) );
     
    3335
    3436        /**
    3537         * Test the whole array as input
     38         *
     39         * @covers ::urlencode_deep
    3640         */
    3741        public function test_urlencode_deep_should_encode_all_values_in_array() {
    3842                $data = $this->data_test_values();
  • tests/phpunit/tests/formatting/URLShorten.php

     
    44 * @group formatting
    55 */
    66class Tests_Formatting_URLShorten extends WP_UnitTestCase {
     7
     8        /**
     9         * @covers ::url_shorten
     10         */
    711        function test_shorten_url() {
    812                $tests = array(
    913                        'wordpress\.org/about/philosophy'            => 'wordpress\.org/about/philosophy', // No longer strips slashes.
  • tests/phpunit/tests/formatting/Utf8UriEncode.php

     
    1010         * are dealt with elsewhere.
    1111         *
    1212         * @dataProvider data
     13         *
     14         * @covers ::utf8_uri_encode
    1315         */
    1416        function test_percent_encodes_non_reserved_characters( $utf8, $urlencoded ) {
    1517                $this->assertSame( $urlencoded, utf8_uri_encode( $utf8 ) );
     
    1719
    1820        /**
    1921         * @dataProvider data
     22         *
     23         * @covers ::utf8_uri_encode
    2024         */
    2125        function test_output_is_not_longer_than_optional_length_argument( $utf8, $unused_for_this_test ) {
    2226                $max_length = 30;
  • tests/phpunit/tests/formatting/WPBasename.php

     
    55 */
    66class Tests_Formatting_WP_Basename extends WP_UnitTestCase {
    77
     8        /**
     9         * @covers ::wp_basename
     10         */
    811        function test_wp_basename_unix() {
    912                $this->assertSame(
    1013                        'file',
     
    1215                );
    1316        }
    1417
     18        /**
     19         * @covers ::wp_basename
     20         */
    1521        function test_wp_basename_unix_utf8_support() {
    1622                $this->assertSame(
    1723                        'žluťoučký kůň.txt',
     
    2127
    2228        /**
    2329         * @ticket 22138
     30         *
     31         * @covers ::wp_basename
    2432         */
    2533        function test_wp_basename_windows() {
    2634                $this->assertSame(
     
    3139
    3240        /**
    3341         * @ticket 22138
     42         *
     43         * @covers ::wp_basename
    3444         */
    3545        function test_wp_basename_windows_utf8_support() {
    3646                $this->assertSame(
  • tests/phpunit/tests/formatting/WpHtmlEditPre.php

     
    1313        /*
    1414         * Only fails in PHP 5.4 onwards
    1515         * @ticket 23688
     16         *
     17         * @covers ::wp_htmledit_pre
    1618         */
    1719        function test_wp_htmledit_pre_charset_iso_8859_1() {
    1820                add_filter( 'pre_option_blog_charset', array( $this, '_charset_iso_8859_1' ) );
     
    2729
    2830        /*
    2931         * @ticket 23688
     32         *
     33         * @covers ::wp_htmledit_pre
    3034         */
    3135        function test_wp_htmledit_pre_charset_utf_8() {
    3236                add_filter( 'pre_option_blog_charset', array( $this, '_charset_utf_8' ) );
  • tests/phpunit/tests/formatting/WpHtmlSplit.php

     
    99         * Basic functionality goes here.
    1010         *
    1111         * @dataProvider data_basic_features
     12         *
     13         * @covers ::wp_html_split
    1214         */
    1315        function test_basic_features( $input, $output ) {
    1416                return $this->assertSame( $output, wp_html_split( $input ) );
     
    3941         * Automated performance testing of the main regex.
    4042         *
    4143         * @dataProvider data_whole_posts
     44         *
     45         * @covers ::preg_split
    4246         */
    4347        function test_pcre_performance( $input ) {
    4448                $regex  = get_html_split_regex();
  • tests/phpunit/tests/formatting/WPMakeLinkRelative.php

     
    55 */
    66class Tests_Formatting_WPMakeLinkRelative extends WP_UnitTestCase {
    77
     8        /**
     9         * @covers ::wp_make_link_relative
     10         */
    811        public function test_wp_make_link_relative_with_http_scheme() {
    912                $link          = 'http://example.com/this-is-a-test-http-url/';
    1013                $relative_link = wp_make_link_relative( $link );
     
    1114                $this->assertSame( '/this-is-a-test-http-url/', $relative_link );
    1215        }
    1316
     17
     18        /**
     19         * @covers ::wp_make_link_relative
     20         */
    1421        public function test_wp_make_link_relative_with_https_scheme() {
    1522                $link          = 'https://example.com/this-is-a-test-https-url/';
    1623                $relative_link = wp_make_link_relative( $link );
     
    1926
    2027        /**
    2128         * @ticket 30373
     29         *
     30         * @covers ::wp_make_link_relative
    2231         */
    2332        public function test_wp_make_link_relative_with_no_scheme() {
    2433                $link          = '//example.com/this-is-a-test-schemeless-url/';
     
    2837
    2938        /**
    3039         * @ticket 30373
     40         *
     41         * @covers ::wp_make_link_relative
    3142         */
    3243        public function test_wp_make_link_relative_should_retain_URL_param_that_is_also_a_URL() {
    3344                $link          = 'https://example.com/this-is-a-test/?redirect=https://example.org/a-different-test-post/';
     
    3748
    3849        /**
    3950         * @ticket 26819
     51         *
     52         * @covers ::wp_make_link_relative
    4053         */
    4154        function test_wp_make_link_relative_with_no_path() {
    4255                $link          = 'http://example.com';
  • tests/phpunit/tests/formatting/WPRelNoFollow.php

     
    77
    88        /**
    99         * @ticket 9959
     10         *
     11         * @covers ::wp_rel_nofollow
    1012         */
    1113        public function test_add_no_follow() {
    1214                $content  = '<p>This is some cool <a href="/">Code</a></p>';
     
    1618
    1719        /**
    1820         * @ticket 9959
     21         *
     22         * @covers ::wp_rel_nofollow
    1923         */
    2024        public function test_convert_no_follow() {
    2125                $content  = '<p>This is some cool <a href="/" rel="weird">Code</a></p>';
     
    2630        /**
    2731         * @ticket 11360
    2832         * @dataProvider data_wp_rel_nofollow
     33         *
     34         * @covers ::wp_rel_nofollow
    2935         */
    3036        public function test_wp_rel_nofollow( $input, $output ) {
    3137                return $this->assertSame( wp_slash( $output ), wp_rel_nofollow( $input ) );
  • tests/phpunit/tests/formatting/WPRelUgc.php

     
    77
    88        /**
    99         * @ticket 48022
     10         *
     11         * @covers ::wp_rel_ugc
    1012         */
    1113        public function test_add_ugc() {
    1214                $content  = '<p>This is some cool <a href="/">Code</a></p>';
     
    1618
    1719        /**
    1820         * @ticket 48022
     21         *
     22         * @covers ::wp_rel_ugc
    1923         */
    2024        public function test_convert_ugc() {
    2125                $content  = '<p>This is some cool <a href="/" rel="weird">Code</a></p>';
     
    2630        /**
    2731         * @ticket 48022
    2832         * @dataProvider data_wp_rel_ugc
     33         *
     34         * @covers ::wp_rel_ugc
    2935         */
    3036        public function test_wp_rel_ugc( $input, $output ) {
    3137                return $this->assertSame( wp_slash( $output ), wp_rel_ugc( $input ) );
     
    7581                );
    7682        }
    7783
     84        /**
     85         * @covers ::wp_rel_ugc
     86         */
    7887        public function test_append_ugc_with_valueless_attribute() {
    7988                $content  = '<p>This is some cool <a href="demo.com" download rel="hola">Code</a></p>';
    8089                $expected = '<p>This is some cool <a href=\"demo.com\" download rel=\"hola nofollow ugc\">Code</a></p>';
  • tests/phpunit/tests/formatting/WpReplaceInHtmlTags.php

     
    88         * Check for expected behavior of new function wp_replace_in_html_tags().
    99         *
    1010         * @dataProvider data_wp_replace_in_html_tags
     11         *
     12         * @covers ::wp_replace_in_html_tags
    1113         */
    1214        function test_wp_replace_in_html_tags( $input, $output ) {
    1315                return $this->assertSame( $output, wp_replace_in_html_tags( $input, array( "\n" => ' ' ) ) );
  • tests/phpunit/tests/formatting/WpRichEditPre.php

     
    1313        /*
    1414         * Only fails in PHP 5.4 onwards
    1515         * @ticket 23688
     16         *
     17         * @covers ::wp_richedit_pre
    1618         */
    1719        function test_wp_richedit_pre_charset_iso_8859_1() {
    1820                add_filter( 'pre_option_blog_charset', array( $this, '_charset_iso_8859_1' ) );
     
    2729
    2830        /*
    2931         * @ticket 23688
     32         *
     33         * @covers ::wp_richedit_pre
    3034         */
    3135        function test_wp_richedit_pre_charset_utf_8() {
    3236                add_filter( 'pre_option_blog_charset', array( $this, '_charset_utf_8' ) );
  • tests/phpunit/tests/formatting/WPSlash.php

     
    1212         *
    1313         * @param string $value
    1414         * @param string $expected
     15         *
     16         * @covers ::wp_slash
    1517         */
    1618        public function test_wp_slash( $value, $expected ) {
    1719                $this->assertSame( $expected, wp_slash( $value ) );
     
    5355
    5456        /**
    5557         * @ticket 24106
     58         *
     59         * @covers ::wp_slash
    5660         */
    5761        function test_adds_slashes() {
    5862                $old = "I can't see, isn't that it?";
     
    6569
    6670        /**
    6771         * @ticket 24106
     72         *
     73         * @covers ::wp_slash
    6874         */
    6975        function test_preserves_original_datatype() {
    7076
     
    9197
    9298        /**
    9399         * @ticket 24106
     100         *
     101         * @covers ::wp_slash
    94102         */
    95103        function test_add_even_more_slashes() {
    96104                $old = 'single\\slash double\\\\slash triple\\\\\\slash';
  • tests/phpunit/tests/formatting/WPSpecialchars.php

     
    44 * @group formatting
    55 */
    66class Tests_Formatting_WPSpecialchars extends WP_UnitTestCase {
     7
     8        /**
     9         * @covers ::_wp_specialchars
     10         */
    711        function test_wp_specialchars_basics() {
    812                $html = '&amp;&lt;hello world&gt;';
    913                $this->assertSame( $html, _wp_specialchars( $html ) );
     
    1216                $this->assertSame( $double, _wp_specialchars( $html, ENT_NOQUOTES, false, true ) );
    1317        }
    1418
     19        /**
     20         * @covers ::_wp_specialchars
     21         */
    1522        function test_allowed_entity_names() {
    1623                global $allowedentitynames;
    1724
     
    2633                }
    2734        }
    2835
     36        /**
     37         * @covers ::_wp_specialchars
     38         */
    2939        function test_not_allowed_entity_names() {
    3040                $ents = array( 'iacut', 'aposs', 'pos', 'apo', 'apo?', 'apo.*', '.*apo.*', 'apos ', ' apos', ' apos ' );
    3141
     
    3646                }
    3747        }
    3848
     49        /**
     50         * @covers ::_wp_specialchars
     51         */
    3952        function test_optionally_escapes_quotes() {
    4053                $source = "\"'hello!'\"";
    4154                $this->assertSame( '"&#039;hello!&#039;"', _wp_specialchars( $source, 'single' ) );
     
    4962         *
    5063         * @ticket 17780
    5164         * @dataProvider data_double_encoding
     65         *
     66         * @covers ::_wp_specialchars
    5267         */
    5368        function test_double_encoding( $input, $output ) {
    5469                return $this->assertSame( $output, _wp_specialchars( $input, ENT_NOQUOTES, false, true ) );
     
    7691         *
    7792         * @ticket 17780
    7893         * @dataProvider data_no_double_encoding
     94         *
     95         * @covers ::_wp_specialchars
    7996         */
    8097        function test_no_double_encoding( $input, $output ) {
    8198                return $this->assertSame( $output, _wp_specialchars( $input, ENT_NOQUOTES, false, false ) );
  • tests/phpunit/tests/formatting/WPStripAllTags.php

     
    66 */
    77class Tests_Formatting_WPStripAllTags extends WP_UnitTestCase {
    88
     9        /**
     10         * @covers ::wp_strip_all_tags
     11         */
    912        function test_wp_strip_all_tags() {
    1013
    1114                $text = 'lorem<br />ipsum';
  • tests/phpunit/tests/formatting/WPTargetedLinkRel.php

     
    66 */
    77class Tests_Targeted_Link_Rel extends WP_UnitTestCase {
    88
     9        /**
     10         * @covers ::wp_targeted_link_rel
     11         */
    912        public function test_add_to_links_with_target_blank() {
    1013                $content  = '<p>Links: <a href="/" target="_blank">No rel</a></p>';
    1114                $expected = '<p>Links: <a href="/" target="_blank" rel="noopener">No rel</a></p>';
     
    1215                $this->assertSame( $expected, wp_targeted_link_rel( $content ) );
    1316        }
    1417
     18        /**
     19         * @covers ::wp_targeted_link_rel
     20         */
    1521        public function test_add_to_links_with_target_foo() {
    1622                $content  = '<p>Links: <a href="/" target="foo">No rel</a></p>';
    1723                $expected = '<p>Links: <a href="/" target="foo" rel="noopener">No rel</a></p>';
     
    1824                $this->assertSame( $expected, wp_targeted_link_rel( $content ) );
    1925        }
    2026
     27        /**
     28         * @covers ::wp_targeted_link_rel
     29         */
    2130        public function test_target_as_first_attribute() {
    2231                $content  = '<p>Links: <a target="_blank" href="#">No rel</a></p>';
    2332                $expected = '<p>Links: <a target="_blank" href="#" rel="noopener">No rel</a></p>';
     
    2433                $this->assertSame( $expected, wp_targeted_link_rel( $content ) );
    2534        }
    2635
     36        /**
     37         * @covers ::wp_targeted_link_rel
     38         */
    2739        public function test_add_to_existing_rel() {
    2840                $content  = '<p>Links: <a href="/" rel="existing values" target="_blank">Existing rel</a></p>';
    2941                $expected = '<p>Links: <a href="/" rel="existing values noopener" target="_blank">Existing rel</a></p>';
     
    3042                $this->assertSame( $expected, wp_targeted_link_rel( $content ) );
    3143        }
    3244
     45        /**
     46         * @covers ::wp_targeted_link_rel
     47         */
    3348        public function test_no_duplicate_values_added() {
    3449                $content  = '<p>Links: <a href="/" rel="existing noopener values" target="_blank">Existing rel</a></p>';
    3550                $expected = '<p>Links: <a href="/" rel="existing noopener values" target="_blank">Existing rel</a></p>';
     
    3651                $this->assertSame( $expected, wp_targeted_link_rel( $content ) );
    3752        }
    3853
     54        /**
     55         * @covers ::wp_targeted_link_rel
     56         */
    3957        public function test_rel_with_single_quote_delimiter() {
    4058                $content  = '<p>Links: <a href="/" rel=\'existing values\' target="_blank">Existing rel</a></p>';
    4159                $expected = '<p>Links: <a href="/" rel="existing values noopener" target="_blank">Existing rel</a></p>';
     
    4260                $this->assertSame( $expected, wp_targeted_link_rel( $content ) );
    4361        }
    4462
     63        /**
     64         * @covers ::wp_targeted_link_rel
     65         */
    4566        public function test_rel_with_no_delimiter() {
    4667                $content  = '<p>Links: <a href="/" rel=existing target="_blank">Existing rel</a></p>';
    4768                $expected = '<p>Links: <a href="/" rel="existing noopener" target="_blank">Existing rel</a></p>';
     
    4869                $this->assertSame( $expected, wp_targeted_link_rel( $content ) );
    4970        }
    5071
     72        /**
     73         * @covers ::wp_targeted_link_rel
     74         */
    5175        public function test_rel_value_spaced_and_no_delimiter() {
    5276                $content  = '<p>Links: <a href="/" rel = existing target="_blank">Existing rel</a></p>';
    5377                $expected = '<p>Links: <a href="/" rel="existing noopener" target="_blank">Existing rel</a></p>';
     
    5478                $this->assertSame( $expected, wp_targeted_link_rel( $content ) );
    5579        }
    5680
     81        /**
     82         * @covers ::wp_targeted_link_rel
     83         */
    5784        public function test_escaped_quotes() {
    5885                $content  = '<p>Links: <a href=\"/\" rel=\"existing values\" target=\"_blank\">Existing rel</a></p>';
    5986                $expected = '<p>Links: <a href=\"/\" rel=\"existing values noopener\" target=\"_blank\">Existing rel</a></p>';
     
    6087                $this->assertSame( $expected, wp_targeted_link_rel( $content ) );
    6188        }
    6289
     90        /**
     91         * @covers ::wp_targeted_link_rel
     92         */
    6393        public function test_ignore_links_with_no_target() {
    6494                $content  = '<p>Links: <a href="/" target="_blank">Change me</a> <a href="/">Do not change me</a></p>';
    6595                $expected = '<p>Links: <a href="/" target="_blank" rel="noopener">Change me</a> <a href="/">Do not change me</a></p>';
     
    70100         * Ensure empty rel attributes are not added.
    71101         *
    72102         * @ticket 45352
     103         *
     104         * @covers ::wp_targeted_link_rel
    73105         */
    74106        public function test_ignore_if_wp_targeted_link_rel_nulled() {
    75107                add_filter( 'wp_targeted_link_rel', '__return_empty_string' );
     
    82114         * Ensure default content filters are added.
    83115         *
    84116         * @ticket 45292
     117         *
     118         * @covers ::wp_targeted_link_rel
    85119         */
    86120        public function test_wp_targeted_link_rel_filters_run() {
    87121                $content  = '<p>Links: <a href="/" target="_blank">No rel</a></p>';
     
    100134         * Ensure JSON format is preserved when relation attribute (rel) is missing.
    101135         *
    102136         * @ticket 46316
     137         *
     138         * @covers ::wp_targeted_link_rel
    103139         */
    104140        public function test_wp_targeted_link_rel_should_preserve_json() {
    105141                $content  = '<p>Links: <a href=\"\/\" target=\"_blank\">No rel<\/a><\/p>';
     
    111147         * Ensure the content of style and script tags are not processed
    112148         *
    113149         * @ticket 47244
     150         *
     151         * @covers ::wp_targeted_link_rel
    114152         */
    115153        public function test_wp_targeted_link_rel_skips_style_and_scripts() {
    116154                $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>';
     
    122160         * Ensure entirely serialized content is ignored.
    123161         *
    124162         * @ticket 46402
     163         *
     164         * @covers ::wp_targeted_link_rel
    125165         */
    126166        public function test_ignore_entirely_serialized_content() {
    127167                $content  = 'a:1:{s:4:"html";s:52:"<p>Links: <a href="/" target="_blank">No Rel</a></p>";}';
     
    129169                $this->assertSame( $expected, wp_targeted_link_rel( $content ) );
    130170        }
    131171
     172        /**
     173         * @covers ::wp_targeted_link_rel
     174         */
    132175        public function test_wp_targeted_link_rel_tab_separated_values_are_split() {
    133176                $content  = "<p>Links: <a href=\"/\" target=\"_blank\" rel=\"ugc\t\tnoopener\t\">No rel</a></p>";
    134177                $expected = '<p>Links: <a href="/" target="_blank" rel="ugc noopener">No rel</a></p>';
  • tests/phpunit/tests/formatting/WPTexturize.php

     
    44 * @group formatting
    55 */
    66class Tests_Formatting_WPTexturize extends WP_UnitTestCase {
     7
     8        /**
     9         * @covers ::wptexturize
     10         */
    711        function test_dashes() {
    812                $this->assertSame( 'Hey &#8212; boo?', wptexturize( 'Hey -- boo?' ) );
    913                $this->assertSame( '<a href="http://xx--xx">Hey &#8212; boo?</a>', wptexturize( '<a href="http://xx--xx">Hey -- boo?</a>' ) );
    1014        }
    1115
     16        /**
     17         * @covers ::wptexturize
     18         */
    1219        function test_disable() {
    1320                $this->assertSame( '<pre>---&</pre>', wptexturize( '<pre>---&</pre>' ) );
    1421                $this->assertSame( '<pre><code></code>--&</pre>', wptexturize( '<pre><code></code>--&</pre>' ) );
     
    3441
    3542        /**
    3643         * @ticket 1418
     44         *
     45         * @covers ::wptexturize
    3746         */
    3847        function test_bracketed_quotes_1418() {
    3948                $this->assertSame( '(&#8220;test&#8221;)', wptexturize( '("test")' ) );
     
    4352
    4453        /**
    4554         * @ticket 3810
     55         *
     56         * @covers ::wptexturize
    4657         */
    4758        function test_bracketed_quotes_3810() {
    4859                $this->assertSame( 'A dog (&#8220;Hubertus&#8221;) was sent out.', wptexturize( 'A dog ("Hubertus") was sent out.' ) );
     
    5061
    5162        /**
    5263         * @ticket 4539
     64         *
     65         * @covers ::wptexturize
    5366         */
    5467        function test_basic_quotes() {
    5568                $this->assertSame( 'test&#8217;s', wptexturize( 'test\'s' ) );
     
    7386        /**
    7487         * @ticket 4539
    7588         * @ticket 15241
     89         *
     90         * @covers ::wptexturize
    7691         */
    7792        function test_full_sentences_with_unmatched_single_quotes() {
    7893                $this->assertSame(
     
    8398
    8499        /**
    85100         * @ticket 4539
     101         *
     102         * @covers ::wptexturize
    86103         */
    87104        function test_quotes() {
    88105                $this->assertSame( '&#8220;Quoted String&#8221;', wptexturize( '"Quoted String"' ) );
     
    102119
    103120        /**
    104121         * @ticket 4539
     122         *
     123         * @covers ::wptexturize
    105124         */
    106125        function test_quotes_before_s() {
    107126                $this->assertSame( 'test&#8217;s', wptexturize( "test's" ) );
     
    113132
    114133        /**
    115134         * @ticket 4539
     135         *
     136         * @covers ::wptexturize
    116137         */
    117138        function test_quotes_before_numbers() {
    118139                $this->assertSame( 'Class of &#8217;99', wptexturize( "Class of '99" ) );
     
    141162                $this->assertSame( '}&#8221;Class of &#8217;99&#8243;{', wptexturize( "}\"Class of '99\"{" ) );
    142163        }
    143164
     165        /**
     166         * @covers ::wptexturize
     167         */
    144168        function test_quotes_after_numbers() {
    145169                $this->assertSame( 'Class of &#8217;99', wptexturize( "Class of '99" ) );
    146170        }
     
    148172        /**
    149173         * @ticket 4539
    150174         * @ticket 15241
     175         *
     176         * @covers ::wptexturize
    151177         */
    152178        function test_other_html() {
    153179                $this->assertSame( '&#8216;<strong>', wptexturize( "'<strong>" ) );
     
    155181                // $this->assertSame( '&#8220;<strong>Quoted Text</strong>&#8221;,', wptexturize( '"<strong>Quoted Text</strong>",' ) );
    156182        }
    157183
     184        /**
     185         * @covers ::wptexturize
     186         */
    158187        function test_x() {
    159188                $this->assertSame( '14&#215;24', wptexturize( '14x24' ) );
    160189        }
    161190
     191        /**
     192         * @covers ::wptexturize
     193         */
    162194        function test_minutes_seconds() {
    163195                $this->assertSame( '9&#8242;', wptexturize( '9\'' ) );
    164196                $this->assertSame( '9&#8243;', wptexturize( '9"' ) );
     
    172204
    173205        /**
    174206         * @ticket 8775
     207         *
     208         * @covers ::wptexturize
    175209         */
    176210        function test_wptexturize_quotes_around_numbers() {
    177211                $this->assertSame( '&#8220;12345&#8221;', wptexturize( '"12345"' ) );
     
    182216
    183217        /**
    184218         * @ticket 8912
     219         *
     220         * @covers ::wptexturize
    185221         */
    186222        function test_wptexturize_html_comments() {
    187223                $this->assertSame( '<!--[if !IE]>--><!--<![endif]-->', wptexturize( '<!--[if !IE]>--><!--<![endif]-->' ) );
     
    192228        /**
    193229         * @ticket 4539
    194230         * @ticket 15241
     231         *
     232         * @covers ::wptexturize
    195233         */
    196234        function test_entity_quote_cuddling() {
    197235                $this->assertSame( '&nbsp;&#8220;Testing&#8221;', wptexturize( '&nbsp;"Testing"' ) );
     
    200238
    201239        /**
    202240         * @ticket 22823
     241         *
     242         * @covers ::wptexturize
    203243         */
    204244        function test_apostrophes_before_primes() {
    205245                $this->assertSame( 'WordPress 3.5&#8217;s release date', wptexturize( "WordPress 3.5's release date" ) );
     
    207247
    208248        /**
    209249         * @ticket 23185
     250         *
     251         * @covers ::wptexturize
    210252         */
    211253        function test_spaces_around_hyphens() {
    212254                $nbsp = "\xC2\xA0";
     
    230272
    231273        /**
    232274         * @ticket 31030
     275         *
     276         * @covers ::wptexturize
    233277         */
    234278        function test_hyphens_at_start_and_end() {
    235279                $this->assertSame( '&#8211; ', wptexturize( '- ' ) );
     
    247291         * These should never happen, even if the desired output changes some day.
    248292         *
    249293         * @ticket 22692
     294         *
     295         * @covers ::wptexturize
    250296         */
    251297        function test_spaces_around_quotes_never() {
    252298                $nbsp = "\xC2\xA0";
     
    264310         *
    265311         * @ticket 22692
    266312         * @dataProvider data_spaces_around_quotes
     313         *
     314         * @covers ::wptexturize
    267315         */
    268316        function test_spaces_around_quotes( $input, $output ) {
    269317                return $this->assertSame( $output, wptexturize( $input ) );
     
    320368         *
    321369         * @ticket 22692
    322370         * @dataProvider data_apos_before_digits
     371         *
     372         * @covers ::wptexturize
    323373         */
    324374        function test_apos_before_digits( $input, $output ) {
    325375                return $this->assertSame( $output, wptexturize( $input ) );
     
    361411         *
    362412         * @ticket 22692
    363413         * @dataProvider data_opening_single_quote
     414         *
     415         * @covers ::wptexturize
    364416         */
    365417        function test_opening_single_quote( $input, $output ) {
    366418                return $this->assertSame( $output, wptexturize( $input ) );
     
    490542         *
    491543         * @ticket 22692
    492544         * @dataProvider data_double_prime
     545         *
     546         * @covers ::wptexturize
    493547         */
    494548        function test_double_prime( $input, $output ) {
    495549                return $this->assertSame( $output, wptexturize( $input ) );
     
    523577         *
    524578         * @ticket 22692
    525579         * @dataProvider data_single_prime
     580         *
     581         * @covers ::wptexturize
    526582         */
    527583        function test_single_prime( $input, $output ) {
    528584                return $this->assertSame( $output, wptexturize( $input ) );
     
    556612         *
    557613         * @ticket 22692
    558614         * @dataProvider data_contractions
     615         *
     616         * @covers ::wptexturize
    559617         */
    560618        function test_contractions( $input, $output ) {
    561619                return $this->assertSame( $output, wptexturize( $input ) );
     
    597655         *
    598656         * @ticket 22692
    599657         * @dataProvider data_opening_quote
     658         *
     659         * @covers ::wptexturize
    600660         */
    601661        function test_opening_quote( $input, $output ) {
    602662                return $this->assertSame( $output, wptexturize( $input ) );
     
    674734         *
    675735         * @ticket 22692
    676736         * @dataProvider data_closing_quote
     737         *
     738         * @covers ::wptexturize
    677739         */
    678740        function test_closing_quote( $input, $output ) {
    679741                return $this->assertSame( $output, wptexturize( $input ) );
     
    763825         *
    764826         * @ticket 22692
    765827         * @dataProvider data_closing_single_quote
     828         *
     829         * @covers ::wptexturize
    766830         */
    767831        function test_closing_single_quote( $input, $output ) {
    768832                return $this->assertSame( $output, wptexturize( $input ) );
     
    853917         * @ticket 22692
    854918         * @ticket 30445
    855919         * @dataProvider data_multiplication
     920         *
     921         * @covers ::wptexturize
    856922         */
    857923        function test_multiplication( $input, $output ) {
    858924                return $this->assertSame( $output, wptexturize( $input ) );
     
    903969         *
    904970         * @ticket 22692
    905971         * @dataProvider data_ampersand
     972         *
     973         * @covers ::wptexturize
    906974         */
    907975        function test_ampersand( $input, $output ) {
    908976                return $this->assertSame( $output, wptexturize( $input ) );
     
    9681036         *
    9691037         * @ticket 22692
    9701038         * @dataProvider data_cockney
     1039         *
     1040         * @covers ::wptexturize
    9711041         */
    9721042        function test_cockney( $input, $output ) {
    9731043                return $this->assertSame( $output, wptexturize( $input ) );
     
    10291099         *
    10301100         * @ticket 22692
    10311101         * @dataProvider data_smart_dashes
     1102         *
     1103         * @covers ::wptexturize
    10321104         */
    10331105        function test_smart_dashes( $input, $output ) {
    10341106                return $this->assertSame( $output, wptexturize( $input ) );
     
    10821154         *
    10831155         * @ticket 22692
    10841156         * @dataProvider data_misc_static_replacements
     1157         *
     1158         * @covers ::wptexturize
    10851159         */
    10861160        function test_misc_static_replacements( $input, $output ) {
    10871161                return $this->assertSame( $output, wptexturize( $input ) );
     
    11371211         *
    11381212         * @ticket 8775
    11391213         * @dataProvider data_quoted_numbers
     1214         *
     1215         * @covers ::wptexturize
    11401216         */
    11411217        function test_quoted_numbers( $input, $output ) {
    11421218                return $this->assertSame( $output, wptexturize( $input ) );
     
    11881264         *
    11891265         * @ticket 20342
    11901266         * @dataProvider data_quotes_and_dashes
     1267         *
     1268         * @covers ::wptexturize
    11911269         */
    11921270        function test_quotes_and_dashes( $input, $output ) {
    11931271                return $this->assertSame( $output, wptexturize( $input ) );
     
    12511329         *
    12521330         * @ticket 12690
    12531331         * @dataProvider data_tag_avoidance
     1332         *
     1333         * @covers ::wptexturize
    12541334         */
    12551335        function test_tag_avoidance( $input, $output ) {
    12561336                return $this->assertSame( $output, wptexturize( $input ) );
     
    14741554         *
    14751555         * @ticket 26850
    14761556         * @dataProvider data_year_abbr
     1557         *
     1558         * @covers ::wptexturize
    14771559         */
    14781560        function test_year_abbr( $input, $output ) {
    14791561                return $this->assertSame( $output, wptexturize( $input ) );
     
    15631645         *
    15641646         * @ticket 27426
    15651647         * @dataProvider data_translate
     1648         *
     1649         * @covers ::wptexturize
    15661650         */
    15671651        function test_translate( $input, $output ) {
    15681652                add_filter( 'gettext_with_context', array( $this, 'filter_translate' ), 10, 4 );
     
    17901874         *
    17911875         * @ticket 28483
    17921876         * @dataProvider data_element_stack
     1877         *
     1878         * @covers ::wptexturize
    17931879         */
    17941880        function test_element_stack( $input, $output ) {
    17951881                return $this->assertSame( $output, wptexturize( $input ) );
     
    18411927         *
    18421928         * @ticket 29557
    18431929         * @dataProvider data_unregistered_shortcodes
     1930         *
     1931         * @covers ::wptexturize
    18441932         */
    18451933        function test_unregistered_shortcodes( $input, $output ) {
    18461934                add_filter( 'no_texturize_shortcodes', array( $this, 'filter_shortcodes' ), 10, 1 );
     
    19262014         *
    19272015         * @ticket 29256
    19282016         * @dataProvider data_primes_vs_quotes
     2017         *
     2018         * @covers ::wptexturize
    19292019         */
    19302020        function test_primes_vs_quotes( $input, $output ) {
    19312021                return $this->assertSame( $output, wptexturize( $input ) );
     
    19882078         *
    19892079         * @ticket 29256
    19902080         * @dataProvider data_primes_quotes_translation
     2081         *
     2082         * @covers ::wptexturize
    19912083         */
    19922084        function test_primes_quotes_translation( $input, $output ) {
    19932085                add_filter( 'gettext_with_context', array( $this, 'filter_translate2' ), 10, 4 );
     
    20812173         * Automated performance testing of the main regex.
    20822174         *
    20832175         * @dataProvider data_whole_posts
     2176         *
     2177         * @covers ::preg_split
    20842178         */
    20852179        function test_pcre_performance( $input ) {
    20862180                global $shortcode_tags;
     
    21012195         * Ensure that a trailing less-than symbol doesn't cause a PHP warning.
    21022196         *
    21032197         * @ticket 35864
     2198         *
     2199         * @covers ::wptexturize
    21042200         */
    21052201        function test_trailing_less_than() {
    21062202                $this->assertSame( 'F&#8211;oo<', wptexturize( 'F--oo<', true ) );
  • tests/phpunit/tests/formatting/WpTrimExcerpt.php

     
    77class Tests_Formatting_WpTrimExcerpt extends WP_UnitTestCase {
    88        /**
    99         * @ticket 25349
     10         *
     11         * @covers ::wp_trim_excerpt
    1012         */
    1113        public function test_secondary_loop_respect_more() {
    1214                $post1 = self::factory()->post->create(
     
    3840
    3941        /**
    4042         * @ticket 25349
     43         *
     44         * @covers ::wp_trim_excerpt
    4145         */
    4246        public function test_secondary_loop_respect_nextpage() {
    4347                $post1 = self::factory()->post->create(
     
    6973
    7074        /**
    7175         * @ticket 51042
     76         *
     77         * @covers ::wp_trim_excerpt
    7278         */
    7379        public function test_should_generate_excerpt_for_empty_values() {
    7480                $post = self::factory()->post->create(
  • tests/phpunit/tests/formatting/WPTrimWords.php

     
    1414         */
    1515        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.';
    1616
     17        /**
     18         * @covers ::wp_trim_words
     19         */
    1720        function test_trims_to_55_by_default() {
    1821                $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&hellip;';
    1922                $this->assertSame( $trimmed, wp_trim_words( $this->long_text ) );
    2023        }
    2124
     25        /**
     26         * @covers ::wp_trim_words
     27         */
    2228        function test_trims_to_10() {
    2329                $trimmed = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce varius&hellip;';
    2430                $this->assertSame( $trimmed, wp_trim_words( $this->long_text, 10 ) );
    2531        }
    2632
     33        /**
     34         * @covers ::wp_trim_words
     35         */
    2736        function test_trims_to_5_and_uses_custom_more() {
    2837                $trimmed = 'Lorem ipsum dolor sit amet,[...] Read on!';
    2938                $this->assertSame( $trimmed, wp_trim_words( $this->long_text, 5, '[...] Read on!' ) );
    3039        }
    3140
     41        /**
     42         * @covers ::wp_trim_words
     43         */
    3244        function test_strips_tags_before_trimming() {
    3345                $text    = 'This text contains a <a href="http://wordpress.org"> link </a> to WordPress.org!';
    3446                $trimmed = 'This text contains a link&hellip;';
     
    3749
    3850        /**
    3951         * @ticket 18726
     52         *
     53         * @covers ::wp_trim_words
    4054         */
    4155        function test_strips_script_and_style_content() {
    4256                $trimmed = 'This text contains. It should go.';
     
    4862                $this->assertSame( $trimmed, wp_trim_words( $text ) );
    4963        }
    5064
     65        /**
     66         * @covers ::wp_trim_words
     67         */
    5168        function test_doesnt_trim_short_text() {
    5269                $text = 'This is some short text.';
    5370                $this->assertSame( $text, wp_trim_words( $text ) );
     
    5572
    5673        /**
    5774         * @ticket 44541
     75         *
     76         * @covers ::wp_trim_words
    5877         */
    5978        function test_trims_to_20_counted_by_chars() {
    6079                switch_to_locale( 'ja_JP' );
     
    6685
    6786        /**
    6887         * @ticket 44541
     88         *
     89         * @covers ::wp_trim_words
    6990         */
    7091        function test_trims_to_20_counted_by_chars_with_double_width_chars() {
    7192                switch_to_locale( 'ja_JP' );
     
    7899
    79100        /**
    80101         * @ticket 47867
     102         *
     103         * @covers ::wp_trim_words
    81104         */
    82105        function test_works_with_non_numeric_num_words() {
    83106                $this->assertSame( '', wp_trim_words( $this->long_text, '', '' ) );
  • tests/phpunit/tests/formatting/Zeroise.php

     
    44 * @group formatting
    55 */
    66class Tests_Formatting_Zeroise extends WP_UnitTestCase {
     7
     8        /**
     9         * @covers ::zeroise
     10         */
    711        function test_pads_with_leading_zeroes() {
    812                $this->assertSame( '00005', zeroise( 5, 5 ) );
    913        }
    1014
     15        /**
     16         * @covers ::zeroise
     17         */
    1118        function test_does_nothing_if_input_is_already_longer() {
    1219                $this->assertSame( '5000000', zeroise( 5000000, 2 ) );
    1320        }