Make WordPress Core

Changeset 55562


Ignore:
Timestamp:
03/19/2023 12:03:30 PM (13 months ago)
Author:
SergeyBiryukov
Message:

Tests: Use the data_ prefix for various data provider methods.

This aims to bring more consistency to the test suite, as the vast majority of data providers already use that prefix.

Includes moving some data providers next to the tests they are used in.

Follow-up to [55464].

See #57841.

Location:
trunk/tests/phpunit/tests
Files:
60 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/admin/includesTemplate.php

    r53371 r55562  
    223223     * @covers ::settings_errors
    224224     * @global array $wp_settings_errors
    225      * @dataProvider settings_errors_css_classes_provider
     225     * @dataProvider data_settings_errors_css_classes
    226226     */
    227227    public function test_settings_errors_css_classes( $type, $expected ) {
     
    242242    }
    243243
    244     public function settings_errors_css_classes_provider() {
     244    public function data_settings_errors_css_classes() {
    245245        return array(
    246246            array( 'error', 'notice-error' ),
  • trunk/tests/phpunit/tests/admin/wpPrivacyRequestsTable.php

    r55337 r55562  
    7474     * @param string      $expected Expected in SQL query.
    7575
    76      * @dataProvider data_test_columns_should_be_sortable
     76     * @dataProvider data_columns_should_be_sortable
    7777     * @covers WP_Privacy_Requests_Table::prepare_items
    7878     * @ticket 43960
     
    126126     * }
    127127     */
    128     public function data_test_columns_should_be_sortable() {
     128    public function data_columns_should_be_sortable() {
    129129        return array(
    130130            // Default order (ID) DESC.
  • trunk/tests/phpunit/tests/compat/mbStrlen.php

    r55036 r55562  
    1818
    1919    /**
    20      * @dataProvider utf8_string_lengths
     20     * @dataProvider data_utf8_string_lengths
    2121     */
    2222    public function test_mb_strlen( $input_string, $expected_character_length ) {
     
    2525
    2626    /**
    27      * @dataProvider utf8_string_lengths
     27     * @dataProvider data_utf8_string_lengths
    2828     */
    2929    public function test_mb_strlen_via_regex( $input_string, $expected_character_length ) {
     
    3434
    3535    /**
    36      * @dataProvider utf8_string_lengths
     36     * @dataProvider data_utf8_string_lengths
    3737     */
    3838    public function test_8bit_mb_strlen( $input_string, $expected_character_length, $expected_byte_length ) {
     
    4545     * @return array
    4646     */
    47     public function utf8_string_lengths() {
     47    public function data_utf8_string_lengths() {
    4848        return array(
    4949            array(
  • trunk/tests/phpunit/tests/compat/mbSubstr.php

    r55037 r55562  
    1818
    1919    /**
    20      * @dataProvider utf8_substrings
     20     * @dataProvider data_utf8_substrings
    2121     */
    2222    public function test_mb_substr( $input_string, $start, $length, $expected_character_substring ) {
     
    2525
    2626    /**
    27      * @dataProvider utf8_substrings
     27     * @dataProvider data_utf8_substrings
    2828     */
    2929    public function test_mb_substr_via_regex( $input_string, $start, $length, $expected_character_substring ) {
     
    3434
    3535    /**
    36      * @dataProvider utf8_substrings
     36     * @dataProvider data_utf8_substrings
    3737     */
    3838    public function test_8bit_mb_substr( $input_string, $start, $length, $expected_character_substring, $expected_byte_substring ) {
     
    4545     * @return array
    4646     */
    47     public function utf8_substrings() {
     47    public function data_utf8_substrings() {
    4848        return array(
    4949            array(
  • trunk/tests/phpunit/tests/date/dateI18n.php

    r54230 r55562  
    204204     * @ticket 25768
    205205     *
    206      * @dataProvider dst_times
     206     * @dataProvider data_should_handle_dst
    207207     *
    208208     * @param string $time     Time to test in Y-m-d H:i:s format.
     
    220220    }
    221221
    222     public function dst_times() {
     222    public function data_should_handle_dst() {
    223223        return array(
    224224            'Before DST start' => array( '2019-03-31 02:59:00', 'Europe/Helsinki' ),
  • trunk/tests/phpunit/tests/date/query.php

    r55465 r55562  
    532532     * @ticket 41782
    533533     *
    534      * @dataProvider mysql_datetime_input_provider
     534     * @dataProvider data_build_mysql_datetime
    535535     *
    536536     * @param array|string $datetime       Array or string date input.
     
    547547    }
    548548
    549     public function mysql_datetime_input_provider() {
     549    public function data_build_mysql_datetime() {
    550550        return array(
    551551            array( '2019-06-04T08:18:24+03:00', '2019-06-04 05:18:24' ),
     
    565565     * @ticket 41782
    566566     *
    567      * @dataProvider mysql_datetime_input_provider_custom_timezone
     567     * @dataProvider data_build_mysql_datetime_with_custom_timezone
    568568     *
    569569     * @param array|string $datetime       Array or string date input.
     
    583583    }
    584584
    585     public function mysql_datetime_input_provider_custom_timezone() {
     585    public function data_build_mysql_datetime_with_custom_timezone() {
    586586        return array(
    587587            array( '2019-06-04T08:18:24+03:00', '2019-06-04 08:18:24' ),
  • trunk/tests/phpunit/tests/date/wpTimezone.php

    r54230 r55562  
    2323     * @ticket 24730
    2424     *
    25      * @dataProvider timezone_offset_provider
     25     * @dataProvider data_should_convert_gmt_offset
    2626     *
    2727     * @param float  $gmt_offset Numeric offset from UTC.
     
    4040
    4141    /**
    42      * @ticket 24730
    43      */
    44     public function test_should_return_timezone_string() {
    45         update_option( 'timezone_string', 'Europe/Helsinki' );
    46 
    47         $this->assertSame( 'Europe/Helsinki', wp_timezone_string() );
    48 
    49         $timezone = wp_timezone();
    50 
    51         $this->assertSame( 'Europe/Helsinki', $timezone->getName() );
    52     }
    53 
    54     /**
    55      * Ensures that deprecated timezone strings are handled correctly.
    56      *
    57      * @ticket 56468
    58      */
    59     public function test_should_return_deprecated_timezone_string() {
    60         $tz_string = 'America/Buenos_Aires'; // This timezone was deprecated pre-PHP 5.6.
    61         update_option( 'timezone_string', $tz_string );
    62 
    63         $this->assertSame( $tz_string, wp_timezone_string() );
    64 
    65         $timezone = wp_timezone();
    66 
    67         $this->assertSame( $tz_string, $timezone->getName() );
    68     }
    69 
    70     /**
    7142     * Data provider to test numeric offset conversion.
    7243     *
    7344     * @return array
    7445     */
    75     public function timezone_offset_provider() {
     46    public function data_should_convert_gmt_offset() {
    7647        return array(
    7748            array( -12, '-12:00' ),
     
    135106        );
    136107    }
     108
     109    /**
     110     * @ticket 24730
     111     */
     112    public function test_should_return_timezone_string() {
     113        update_option( 'timezone_string', 'Europe/Helsinki' );
     114
     115        $this->assertSame( 'Europe/Helsinki', wp_timezone_string() );
     116
     117        $timezone = wp_timezone();
     118
     119        $this->assertSame( 'Europe/Helsinki', $timezone->getName() );
     120    }
     121
     122    /**
     123     * Ensures that deprecated timezone strings are handled correctly.
     124     *
     125     * @ticket 56468
     126     */
     127    public function test_should_return_deprecated_timezone_string() {
     128        $tz_string = 'America/Buenos_Aires'; // This timezone was deprecated pre-PHP 5.6.
     129        update_option( 'timezone_string', $tz_string );
     130
     131        $this->assertSame( $tz_string, wp_timezone_string() );
     132
     133        $timezone = wp_timezone();
     134
     135        $this->assertSame( $tz_string, $timezone->getName() );
     136    }
    137137}
  • trunk/tests/phpunit/tests/db.php

    r55151 r55562  
    579579     * @param int|string         $column      The column index to retrieve.
    580580     *
    581      * @dataProvider data_test_get_col
     581     * @dataProvider data_get_col
    582582     *
    583583     * @ticket 45299
     
    613613     *     @type int|string         $column      The column index to retrieve.
    614614     */
    615     public function data_test_get_col() {
     615    public function data_get_col() {
    616616        global $wpdb;
    617617
     
    22402240
    22412241    /**
    2242      * @dataProvider parse_db_host_data_provider
     2242     * @dataProvider data_parse_db_host
    22432243     * @ticket 41722
    22442244     * @ticket 54877
     
    22612261    }
    22622262
    2263     public function parse_db_host_data_provider() {
     2263    public function data_parse_db_host() {
    22642264        return array(
    22652265            array(
  • trunk/tests/phpunit/tests/db/charset.php

    r54384 r55562  
    774774     * @ticket 21212
    775775     */
    776     public function data_test_get_table_charset() {
     776    public function data_get_table_charset() {
    777777        $table_name = 'test_get_table_charset';
    778778
     
    789789
    790790    /**
    791      * @dataProvider data_test_get_table_charset
     791     * @dataProvider data_get_table_charset
    792792     * @ticket 21212
    793793     *
     
    815815     * @ticket 21212
    816816     */
    817     public function data_test_get_column_charset() {
     817    public function data_get_column_charset() {
    818818        $table_name = 'test_get_column_charset';
    819819
     
    830830
    831831    /**
    832      * @dataProvider data_test_get_column_charset
     832     * @dataProvider data_get_column_charset
    833833     * @ticket 21212
    834834     *
     
    857857
    858858    /**
    859      * @dataProvider data_test_get_column_charset
     859     * @dataProvider data_get_column_charset
    860860     * @ticket 21212
    861861     *
     
    884884
    885885    /**
    886      * @dataProvider data_test_get_column_charset
     886     * @dataProvider data_get_column_charset
    887887     * @ticket 33501
    888888     *
  • trunk/tests/phpunit/tests/feed/rss2.php

    r54088 r55562  
    488488     * @ticket 4575
    489489     *
    490      * @dataProvider data_test_get_feed_build_date
     490     * @dataProvider data_get_feed_build_date
    491491     */
    492492    public function test_get_feed_build_date( $url, $element ) {
     
    502502
    503503
    504     public function data_test_get_feed_build_date() {
     504    public function data_get_feed_build_date() {
    505505        return array(
    506506            array( '/?feed=rss2', 'rss' ),
  • trunk/tests/phpunit/tests/formatting/balanceTags.php

    r54727 r55562  
    88class Tests_Formatting_BalanceTags extends WP_UnitTestCase {
    99
    10     public function nestable_tags() {
    11         return array(
    12             array( 'article' ),
    13             array( 'aside' ),
    14             array( 'blockquote' ),
    15             array( 'details' ),
    16             array( 'div' ),
    17             array( 'figure' ),
    18             array( 'object' ),
    19             array( 'q' ),
    20             array( 'section' ),
    21             array( 'span' ),
    22         );
    23     }
    24 
    25     // This is a complete(?) listing of valid single/self-closing tags.
    26     public function single_tags() {
    27         return array(
    28             array( 'area' ),
    29             array( 'base' ),
    30             array( 'basefont' ),
    31             array( 'br' ),
    32             array( 'col' ),
    33             array( 'command' ),
    34             array( 'embed' ),
    35             array( 'frame' ),
    36             array( 'hr' ),
    37             array( 'img' ),
    38             array( 'input' ),
    39             array( 'isindex' ),
    40             array( 'link' ),
    41             array( 'meta' ),
    42             array( 'param' ),
    43             array( 'source' ),
    44             array( 'track' ),
    45             array( 'wbr' ),
    46         );
    47     }
    48 
    49     public function supported_traditional_tag_names() {
     10    /**
     11     * @ticket 47014
     12     * @dataProvider data_supported_traditional_tag_names
     13     */
     14    public function test_detects_traditional_tag_names( $tag ) {
     15        $normalized = strtolower( $tag );
     16
     17        $this->assertSame( "<$normalized>inside</$normalized>", balanceTags( "<$tag>inside", true ) );
     18    }
     19
     20    public function data_supported_traditional_tag_names() {
    5021        return array(
    5122            array( 'a' ),
     
    5930    }
    6031
    61     public function supported_custom_element_tag_names() {
     32    /**
     33     * @ticket 47014
     34     * @dataProvider data_supported_custom_element_tag_names
     35     */
     36    public function test_detects_supported_custom_element_tag_names( $tag ) {
     37        $this->assertSame( "<$tag>inside</$tag>", balanceTags( "<$tag>inside", true ) );
     38    }
     39
     40    public function data_supported_custom_element_tag_names() {
    6241        return array(
    6342            array( 'custom-element' ),
     
    7150    }
    7251
    73     public function invalid_tag_names() {
     52    /**
     53     * @ticket 47014
     54     * @dataProvider data_invalid_tag_names
     55     */
     56    public function test_ignores_invalid_tag_names( $input, $output ) {
     57        $this->assertSame( $output, balanceTags( $input, true ) );
     58    }
     59
     60    public function data_invalid_tag_names() {
    7461        return array(
    7562            array( '<0-day>inside', '&lt;0-day>inside' ), // Can't start with a number - handled by the "<3" fix.
     
    7966
    8067    /**
     68     * @ticket 47014
     69     * @dataProvider data_unsupported_valid_tag_names
     70     */
     71    public function test_ignores_unsupported_custom_tag_names( $tag ) {
     72        $this->assertSame( "<$tag>inside", balanceTags( "<$tag>inside", true ) );
     73    }
     74
     75    /**
    8176     * These are valid custom elements but we don't support them yet.
    8277     *
    8378     * @see https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name
    8479     */
    85     public function unsupported_valid_tag_names() {
     80    public function data_unsupported_valid_tag_names() {
    8681        return array(
    8782            // We don't allow ending in a dash.
     
    139134
    140135    /**
     136     * @ticket 47014
     137     * @dataProvider data_supported_invalid_tag_names
     138     */
     139    public function test_detects_supported_invalid_tag_names( $tag ) {
     140        $this->assertSame( "<$tag>inside</$tag>", balanceTags( "<$tag>inside", true ) );
     141    }
     142
     143    /**
    141144     * These are invalid custom elements but we support them right now in order to keep the parser simpler.
    142145     *
    143146     * @see https://w3c.github.io/webcomponents/spec/custom/#valid-custom-element-name
    144147     */
    145     public function supported_invalid_tag_names() {
     148    public function data_supported_invalid_tag_names() {
    146149        return array(
    147150            // Reserved names for custom elements.
     
    158161
    159162    /**
    160      * @ticket 47014
    161      * @dataProvider supported_traditional_tag_names
    162      */
    163     public function test_detects_traditional_tag_names( $tag ) {
    164         $normalized = strtolower( $tag );
    165 
    166         $this->assertSame( "<$normalized>inside</$normalized>", balanceTags( "<$tag>inside", true ) );
    167     }
    168 
    169     /**
    170      * @ticket 47014
    171      * @dataProvider supported_custom_element_tag_names
    172      */
    173     public function test_detects_supported_custom_element_tag_names( $tag ) {
    174         $this->assertSame( "<$tag>inside</$tag>", balanceTags( "<$tag>inside", true ) );
    175     }
    176 
    177     /**
    178      * @ticket 47014
    179      * @dataProvider invalid_tag_names
    180      */
    181     public function test_ignores_invalid_tag_names( $input, $output ) {
    182         $this->assertSame( $output, balanceTags( $input, true ) );
    183     }
    184 
    185     /**
    186      * @ticket 47014
    187      * @dataProvider unsupported_valid_tag_names
    188      */
    189     public function test_ignores_unsupported_custom_tag_names( $tag ) {
    190         $this->assertSame( "<$tag>inside", balanceTags( "<$tag>inside", true ) );
    191     }
    192 
    193     /**
    194      * @ticket 47014
    195      * @dataProvider supported_invalid_tag_names
    196      */
    197     public function test_detects_supported_invalid_tag_names( $tag ) {
    198         $this->assertSame( "<$tag>inside</$tag>", balanceTags( "<$tag>inside", true ) );
    199     }
    200 
    201     /**
    202163     * If a recognized valid single tag appears unclosed, it should get self-closed
    203164     *
    204165     * @ticket 1597
    205      * @dataProvider single_tags
     166     * @dataProvider data_single_tags
    206167     */
    207168    public function test_selfcloses_unclosed_known_single_tags( $tag ) {
     
    214175     *
    215176     * @ticket 1597
    216      * @dataProvider single_tags
     177     * @dataProvider data_single_tags
    217178     */
    218179    public function test_selfcloses_known_single_tags_having_closing_tag( $tag ) {
    219180        $this->assertSame( "<$tag />", balanceTags( "<$tag></$tag>", true ) );
     181    }
     182
     183    // This is a complete(?) listing of valid single/self-closing tags.
     184    public function data_single_tags() {
     185        return array(
     186            array( 'area' ),
     187            array( 'base' ),
     188            array( 'basefont' ),
     189            array( 'br' ),
     190            array( 'col' ),
     191            array( 'command' ),
     192            array( 'embed' ),
     193            array( 'frame' ),
     194            array( 'hr' ),
     195            array( 'img' ),
     196            array( 'input' ),
     197            array( 'isindex' ),
     198            array( 'link' ),
     199            array( 'meta' ),
     200            array( 'param' ),
     201            array( 'source' ),
     202            array( 'track' ),
     203            array( 'wbr' ),
     204        );
    220205    }
    221206
     
    275260
    276261    /**
    277      * @dataProvider nestable_tags
     262     * @dataProvider data_nestable_tags
    278263     */
    279264    public function test_balances_nestable_tags( $tag ) {
     
    292277            $this->assertSame( $expected[ $key ], balanceTags( $inputs[ $key ], true ) );
    293278        }
     279    }
     280
     281    public function data_nestable_tags() {
     282        return array(
     283            array( 'article' ),
     284            array( 'aside' ),
     285            array( 'blockquote' ),
     286            array( 'details' ),
     287            array( 'div' ),
     288            array( 'figure' ),
     289            array( 'object' ),
     290            array( 'q' ),
     291            array( 'section' ),
     292            array( 'span' ),
     293        );
    294294    }
    295295
  • trunk/tests/phpunit/tests/formatting/convertSmilies.php

    r54134 r55562  
    1010
    1111    /**
     12     * @dataProvider data_convert_standard_smilies
     13     *
     14     * Basic Validation Test to confirm that smilies are converted to image
     15     * when use_smilies = 1 and not when use_smilies = 0
     16     */
     17    public function test_convert_standard_smilies( $in_txt, $converted_txt ) {
     18        // Standard smilies, use_smilies: ON.
     19        update_option( 'use_smilies', 1 );
     20
     21        smilies_init();
     22
     23        $this->assertSame( $converted_txt, convert_smilies( $in_txt ) );
     24
     25        // Standard smilies, use_smilies: OFF.
     26        update_option( 'use_smilies', 0 );
     27
     28        $this->assertSame( $in_txt, convert_smilies( $in_txt ) );
     29    }
     30
     31    /**
    1232     * Basic Test Content DataProvider
    1333     *
    1434     * array ( input_txt, converted_output_txt)
    1535     */
    16     public function get_smilies_input_output() {
     36    public function data_convert_standard_smilies() {
    1737        $includes_path = includes_url( 'images/smilies/' );
    1838
     
    4666
    4767    /**
    48      * @dataProvider get_smilies_input_output
    49      *
    50      * Basic Validation Test to confirm that smilies are converted to image
    51      * when use_smilies = 1 and not when use_smilies = 0
    52      */
    53     public function test_convert_standard_smilies( $in_txt, $converted_txt ) {
    54         // Standard smilies, use_smilies: ON.
    55         update_option( 'use_smilies', 1 );
    56 
    57         smilies_init();
    58 
    59         $this->assertSame( $converted_txt, convert_smilies( $in_txt ) );
    60 
    61         // Standard smilies, use_smilies: OFF.
    62         update_option( 'use_smilies', 0 );
    63 
    64         $this->assertSame( $in_txt, convert_smilies( $in_txt ) );
    65     }
    66 
    67     /**
    68      * Custom Smilies Test Content DataProvider
    69      *
    70      * array ( input_txt, converted_output_txt)
    71      */
    72     public function get_custom_smilies_input_output() {
    73         $includes_path = includes_url( 'images/smilies/' );
    74 
    75         return array(
    76             array(
    77                 'Peter Brian Gabriel (born 13 February 1950) is a British singer, musician, and songwriter who rose to fame as the lead vocalist and flautist of the progressive rock group Genesis. :monkey:',
    78                 'Peter Brian Gabriel (born 13 February 1950) is a British singer, musician, and songwriter who rose to fame as the lead vocalist and flautist of the progressive rock group Genesis. <img src="' . $includes_path . 'icon_shock_the_monkey.gif" alt=":monkey:" class="wp-smiley" style="height: 1em; max-height: 1em;" />',
    79             ),
    80             array(
    81                 'Star Wars Jedi Knight :arrow: Jedi Academy is a first and third-person shooter action game set in the Star Wars universe. It was developed by Raven Software and published, distributed and marketed by LucasArts in North America and by Activision in the rest of the world. :nervou:',
    82                 'Star Wars Jedi Knight <img src="' . $includes_path . 'icon_arrow.gif" alt=":arrow:" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Jedi Academy is a first and third-person shooter action game set in the Star Wars universe. It was developed by Raven Software and published, distributed and marketed by LucasArts in North America and by Activision in the rest of the world. <img src="' . $includes_path . 'icon_nervou.gif" alt=":nervou:" class="wp-smiley" style="height: 1em; max-height: 1em;" />',
    83             ),
    84             array(
    85                 ':arrow: monkey: Lorem ipsum dolor sit amet enim. Etiam ullam :PP <br />corper. Suspendisse a pellentesque dui, non felis.<a> :arrow: :arrow</a>',
    86                 '<img src="' . $includes_path . 'icon_arrow.gif" alt=":arrow:" class="wp-smiley" style="height: 1em; max-height: 1em;" /> monkey: Lorem ipsum dolor sit amet enim. Etiam ullam <img src="' . $includes_path . 'icon_tongue.gif" alt=":PP" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <br />corper. Suspendisse a pellentesque dui, non felis.<a> <img src="' . $includes_path . 'icon_arrow.gif" alt=":arrow:" class="wp-smiley" style="height: 1em; max-height: 1em;" /> :arrow</a>',
    87             ),
    88         );
    89     }
    90 
    91     /**
    92      * @dataProvider get_custom_smilies_input_output
     68     * @dataProvider data_convert_custom_smilies
    9369     *
    9470     * Validate Custom Smilies are converted to images when use_smilies = 1
     
    125101    }
    126102
     103    /**
     104     * Custom Smilies Test Content DataProvider
     105     *
     106     * array ( input_txt, converted_output_txt)
     107     */
     108    public function data_convert_custom_smilies() {
     109        $includes_path = includes_url( 'images/smilies/' );
     110
     111        return array(
     112            array(
     113                'Peter Brian Gabriel (born 13 February 1950) is a British singer, musician, and songwriter who rose to fame as the lead vocalist and flautist of the progressive rock group Genesis. :monkey:',
     114                'Peter Brian Gabriel (born 13 February 1950) is a British singer, musician, and songwriter who rose to fame as the lead vocalist and flautist of the progressive rock group Genesis. <img src="' . $includes_path . 'icon_shock_the_monkey.gif" alt=":monkey:" class="wp-smiley" style="height: 1em; max-height: 1em;" />',
     115            ),
     116            array(
     117                'Star Wars Jedi Knight :arrow: Jedi Academy is a first and third-person shooter action game set in the Star Wars universe. It was developed by Raven Software and published, distributed and marketed by LucasArts in North America and by Activision in the rest of the world. :nervou:',
     118                'Star Wars Jedi Knight <img src="' . $includes_path . 'icon_arrow.gif" alt=":arrow:" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Jedi Academy is a first and third-person shooter action game set in the Star Wars universe. It was developed by Raven Software and published, distributed and marketed by LucasArts in North America and by Activision in the rest of the world. <img src="' . $includes_path . 'icon_nervou.gif" alt=":nervou:" class="wp-smiley" style="height: 1em; max-height: 1em;" />',
     119            ),
     120            array(
     121                ':arrow: monkey: Lorem ipsum dolor sit amet enim. Etiam ullam :PP <br />corper. Suspendisse a pellentesque dui, non felis.<a> :arrow: :arrow</a>',
     122                '<img src="' . $includes_path . 'icon_arrow.gif" alt=":arrow:" class="wp-smiley" style="height: 1em; max-height: 1em;" /> monkey: Lorem ipsum dolor sit amet enim. Etiam ullam <img src="' . $includes_path . 'icon_tongue.gif" alt=":PP" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <br />corper. Suspendisse a pellentesque dui, non felis.<a> <img src="' . $includes_path . 'icon_arrow.gif" alt=":arrow:" class="wp-smiley" style="height: 1em; max-height: 1em;" /> :arrow</a>',
     123            ),
     124        );
     125    }
     126
     127    /**
     128     * Validate Conversion of Smilies is ignored in pre-determined tags
     129     * pre, code, script, style
     130     *
     131     * @ticket 16448
     132     * @dataProvider data_ignore_smilies_in_tags
     133     */
     134    public function test_ignore_smilies_in_tags( $element ) {
     135        $includes_path = includes_url( 'images/smilies/' );
     136
     137        $in_str  = 'Do we ingore smilies ;-) in ' . $element . ' tags <' . $element . ' class="foo">My Content Here :?: </' . $element . '>';
     138        $exp_str = "Do we ingore smilies \xf0\x9f\x98\x89 in $element tags <$element class=\"foo\">My Content Here :?: </$element>";
     139
     140        // Standard smilies, use_smilies: ON.
     141        update_option( 'use_smilies', 1 );
     142        smilies_init();
     143
     144        $this->assertSame( $exp_str, convert_smilies( $in_str ) );
     145
     146        // Standard smilies, use_smilies: OFF.
     147        update_option( 'use_smilies', 0 );
     148    }
    127149
    128150    /**
    129151     * DataProvider of HTML elements/tags that smilie matches should be ignored in
    130152     */
    131     public function get_smilies_ignore_tags() {
     153    public function data_ignore_smilies_in_tags() {
    132154        return array(
    133155            array( 'pre' ),
     
    140162
    141163    /**
    142      * Validate Conversion of Smilies is ignored in pre-determined tags
    143      * pre, code, script, style
    144      *
    145      * @ticket 16448
    146      * @dataProvider get_smilies_ignore_tags
    147      */
    148     public function test_ignore_smilies_in_tags( $element ) {
    149         $includes_path = includes_url( 'images/smilies/' );
    150 
    151         $in_str  = 'Do we ingore smilies ;-) in ' . $element . ' tags <' . $element . ' class="foo">My Content Here :?: </' . $element . '>';
    152         $exp_str = "Do we ingore smilies \xf0\x9f\x98\x89 in $element tags <$element class=\"foo\">My Content Here :?: </$element>";
    153 
    154         // Standard smilies, use_smilies: ON.
    155         update_option( 'use_smilies', 1 );
    156         smilies_init();
    157 
    158         $this->assertSame( $exp_str, convert_smilies( $in_str ) );
    159 
    160         // Standard smilies, use_smilies: OFF.
    161         update_option( 'use_smilies', 0 );
     164     * Validate Combinations of Smilies separated by single space
     165     * are converted correctly
     166     *
     167     * @ticket 20124
     168     * @dataProvider data_smilies_combinations
     169     */
     170    public function test_smilies_combinations( $in_txt, $converted_txt ) {
     171        // Custom smilies, use_smilies: ON.
     172        update_option( 'use_smilies', 1 );
     173        smilies_init();
     174
     175        $this->assertSame( $converted_txt, convert_smilies( $in_txt ) );
     176
     177        // Custom smilies, use_smilies: OFF.
     178        update_option( 'use_smilies', 0 );
     179
     180        $this->assertSame( $in_txt, convert_smilies( $in_txt ) );
    162181    }
    163182
     
    165184     * DataProvider of Smilie Combinations
    166185     */
    167     public function get_smilies_combinations() {
     186    public function data_smilies_combinations() {
    168187        $includes_path = includes_url( 'images/smilies/' );
    169188
     
    197216
    198217    /**
    199      * Validate Combinations of Smilies separated by single space
    200      * are converted correctly
    201      *
    202      * @ticket 20124
    203      * @dataProvider get_smilies_combinations
    204      */
    205     public function test_smilies_combinations( $in_txt, $converted_txt ) {
    206         // Custom smilies, use_smilies: ON.
    207         update_option( 'use_smilies', 1 );
    208         smilies_init();
    209 
    210         $this->assertSame( $converted_txt, convert_smilies( $in_txt ) );
    211 
    212         // Custom smilies, use_smilies: OFF.
    213         update_option( 'use_smilies', 0 );
    214 
    215         $this->assertSame( $in_txt, convert_smilies( $in_txt ) );
    216     }
    217 
    218     /**
    219      * DataProvider of Single Smilies input and converted output
    220      */
    221     public function get_single_smilies_input_output() {
    222         $includes_path = includes_url( 'images/smilies/' );
    223 
    224         return array(
    225             array(
    226                 '8-O :-(',
    227                 '8-O :-(',
    228             ),
    229             array(
    230                 '8O :) additional text here :)',
    231                 '8O <img src="' . $includes_path . 'simple-smile.png" alt=":)" class="wp-smiley" style="height: 1em; max-height: 1em;" /> additional text here <img src="' . $includes_path . 'simple-smile.png" alt=":)" class="wp-smiley" style="height: 1em; max-height: 1em;" />',
    232             ),
    233             array(
    234                 ':) :) :) :)',
    235                 '<img src="' . $includes_path . 'simple-smile.png" alt=":)" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <img src="' . $includes_path . 'simple-smile.png" alt=":)" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <img src="' . $includes_path . 'simple-smile.png" alt=":)" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <img src="' . $includes_path . 'simple-smile.png" alt=":)" class="wp-smiley" style="height: 1em; max-height: 1em;" />',
    236             ),
    237         );
    238     }
    239 
    240     /**
    241218     * Validate Smilies are converted for single smilie in
    242219     * the $wpsmiliestrans global array
    243220     *
    244221     * @ticket 25303
    245      * @dataProvider get_single_smilies_input_output
     222     * @dataProvider data_single_smilies_in_wpsmiliestrans
    246223     */
    247224    public function test_single_smilies_in_wpsmiliestrans( $in_txt, $converted_txt ) {
     
    273250    }
    274251
    275     public function get_spaces_around_smilies() {
     252    /**
     253     * DataProvider of Single Smilies input and converted output
     254     */
     255    public function data_single_smilies_in_wpsmiliestrans() {
     256        $includes_path = includes_url( 'images/smilies/' );
     257
     258        return array(
     259            array(
     260                '8-O :-(',
     261                '8-O :-(',
     262            ),
     263            array(
     264                '8O :) additional text here :)',
     265                '8O <img src="' . $includes_path . 'simple-smile.png" alt=":)" class="wp-smiley" style="height: 1em; max-height: 1em;" /> additional text here <img src="' . $includes_path . 'simple-smile.png" alt=":)" class="wp-smiley" style="height: 1em; max-height: 1em;" />',
     266            ),
     267            array(
     268                ':) :) :) :)',
     269                '<img src="' . $includes_path . 'simple-smile.png" alt=":)" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <img src="' . $includes_path . 'simple-smile.png" alt=":)" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <img src="' . $includes_path . 'simple-smile.png" alt=":)" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <img src="' . $includes_path . 'simple-smile.png" alt=":)" class="wp-smiley" style="height: 1em; max-height: 1em;" />',
     270            ),
     271        );
     272    }
     273
     274    /**
     275     * Check that $wp_smiliessearch pattern will match smilies
     276     * between spaces, but never capture those spaces.
     277     *
     278     * Further check that spaces aren't randomly deleted
     279     * or added when replacing the text with an image.
     280     *
     281     * @ticket 22692
     282     * @dataProvider data_spaces_around_smilies
     283     */
     284    public function test_spaces_around_smilies( $in_txt, $converted_txt ) {
     285        // Standard smilies, use_smilies: ON.
     286        update_option( 'use_smilies', 1 );
     287
     288        smilies_init();
     289
     290        $this->assertSame( $converted_txt, convert_smilies( $in_txt ) );
     291
     292        // Standard smilies, use_smilies: OFF.
     293        update_option( 'use_smilies', 0 );
     294    }
     295
     296    public function data_spaces_around_smilies() {
    276297        $nbsp = "\xC2\xA0";
    277298
     
    290311            ),
    291312        );
    292     }
    293 
    294     /**
    295      * Check that $wp_smiliessearch pattern will match smilies
    296      * between spaces, but never capture those spaces.
    297      *
    298      * Further check that spaces aren't randomly deleted
    299      * or added when replacing the text with an image.
    300      *
    301      * @ticket 22692
    302      * @dataProvider get_spaces_around_smilies
    303      */
    304     public function test_spaces_around_smilies( $in_txt, $converted_txt ) {
    305         // Standard smilies, use_smilies: ON.
    306         update_option( 'use_smilies', 1 );
    307 
    308         smilies_init();
    309 
    310         $this->assertSame( $converted_txt, convert_smilies( $in_txt ) );
    311 
    312         // Standard smilies, use_smilies: OFF.
    313         update_option( 'use_smilies', 0 );
    314313    }
    315314
  • trunk/tests/phpunit/tests/formatting/date.php

    r54230 r55562  
    131131     * @ticket 31809
    132132     *
    133      * @dataProvider timezone_provider
    134      *
    135      * @covers ::get_gmt_from_date
    136      */
    137     public function test_gmt_from_date_correct_time( $timezone_string, $gmt_offset ) {
     133     * @dataProvider data_timezone_provider
     134     *
     135     * @covers ::get_gmt_from_date
     136     */
     137    public function test_get_gmt_from_date_correct_time( $timezone_string, $gmt_offset ) {
    138138        update_option( 'timezone_string', $timezone_string );
    139139        update_option( 'gmt_offset', $gmt_offset );
     
    149149     * @ticket 31809
    150150     *
    151      * @dataProvider timezone_provider
    152      *
    153      * @covers ::get_date_from_gmt
    154      */
    155     public function test_date_from_gmt_correct_time( $timezone_string, $gmt_offset ) {
     151     * @dataProvider data_timezone_provider
     152     *
     153     * @covers ::get_date_from_gmt
     154     */
     155    public function test_get_date_from_gmt_correct_time( $timezone_string, $gmt_offset ) {
    156156        update_option( 'timezone_string', $timezone_string );
    157157        update_option( 'gmt_offset', $gmt_offset );
     
    167167     * @ticket 31809
    168168     *
    169      * @dataProvider timezone_provider
     169     * @dataProvider data_timezone_provider
    170170     *
    171171     * @covers ::iso8601_to_datetime
     
    231231     * @return array
    232232     */
    233     public function timezone_provider() {
     233    public function data_timezone_provider() {
    234234        return array(
    235235            array(
  • trunk/tests/phpunit/tests/formatting/ent2ncr.php

    r53562 r55562  
    88class Tests_Formatting_Ent2ncr extends WP_UnitTestCase {
    99    /**
    10      * @dataProvider entities
     10     * @dataProvider data_entities
    1111     */
    1212    public function test_converts_named_entities_to_numeric_character_references( $entity, $ncr ) {
     
    2020     * Comments start with "###".
    2121     */
    22     public function entities() {
     22    public function data_entities() {
    2323        $entities      = file( DIR_TESTDATA . '/formatting/entities.txt' );
    2424        $data_provided = array();
  • trunk/tests/phpunit/tests/formatting/escXml.php

    r53562 r55562  
    1010     * Test basic escaping
    1111     *
    12      * @dataProvider _test_esc_xml_basics_dataprovider
     12     * @dataProvider data_esc_xml_basics
    1313     *
    1414     * @param string $source   The source string to be escaped.
     
    2828     * }
    2929     */
    30     public function _test_esc_xml_basics_dataprovider() {
     30    public function data_esc_xml_basics() {
    3131        return array(
    3232            // Simple string.
     
    8585     * Test that CDATA Sections are not escaped.
    8686     *
    87      * @dataProvider _test_ignores_cdata_sections_dataprovider
     87     * @dataProvider data_ignores_cdata_sections
    8888     *
    8989     * @param string $source   The source string to be escaped.
     
    103103     * }
    104104     */
    105     public function _test_ignores_cdata_sections_dataprovider() {
     105    public function data_ignores_cdata_sections() {
    106106        return array(
    107107            // basic CDATA Section containing chars that would otherwise be escaped if not in a CDATA Section
  • trunk/tests/phpunit/tests/formatting/getBloginfo.php

    r54728 r55562  
    99
    1010    /**
    11      * @dataProvider locales
     11     * @dataProvider data_get_bloginfo_language
    1212     * @ticket 28303
    1313     */
     
    2323    }
    2424
    25     public function locales() {
     25    public function data_get_bloginfo_language() {
    2626        return array(
    2727            // Locale, language code.
  • trunk/tests/phpunit/tests/formatting/getUrlInContent.php

    r53562 r55562  
    99
    1010    /**
     11     * Validate the get_url_in_content function
     12     *
     13     * @dataProvider data_get_url_in_content
     14     */
     15    public function test_get_url_in_content( $in_str, $exp_str ) {
     16        $this->assertSame( $exp_str, get_url_in_content( $in_str ) );
     17    }
     18
     19    /**
    1120     * URL Content Data Provider
    1221     *
    1322     * array ( input_txt, converted_output_txt )
    1423     */
    15     public function get_input_output() {
     24    public function data_get_url_in_content() {
    1625        return array(
    1726            array( // Empty content.
     
    4150        );
    4251    }
    43 
    44     /**
    45      * Validate the get_url_in_content function
    46      *
    47      * @dataProvider get_input_output
    48      */
    49     public function test_get_url_in_content( $in_str, $exp_str ) {
    50         $this->assertSame( $exp_str, get_url_in_content( $in_str ) );
    51     }
    5252}
  • trunk/tests/phpunit/tests/formatting/humanTimeDiff.php

    r53562 r55562  
    1212     * @group formatting
    1313     * @ticket 38773
    14      * @dataProvider data_test_human_time_diff
     14     * @dataProvider data_human_time_diff
    1515     */
    1616    public function test_human_time_diff( $expected, $stopdate, $message ) {
     
    2020
    2121    // Data for test_human_time_diff.
    22     public function data_test_human_time_diff() {
     22    public function data_human_time_diff() {
    2323        return array(
    2424            array(
  • trunk/tests/phpunit/tests/formatting/linksAddTarget.php

    r53562 r55562  
    66 */
    77class Tests_Formatting_LinksAddTarget extends WP_UnitTestCase {
     8
     9    /**
     10     * Validate the normalize_whitespace function
     11     *
     12     * @dataProvider data_links_add_target
     13     */
     14    public function test_links_add_target( $content, $target, $tags, $exp_str ) {
     15        if ( true === is_null( $target ) ) {
     16            $this->assertSame( $exp_str, links_add_target( $content ) );
     17        } elseif ( true === is_null( $tags ) ) {
     18            $this->assertSame( $exp_str, links_add_target( $content, $target ) );
     19        } else {
     20            $this->assertSame( $exp_str, links_add_target( $content, $target, $tags ) );
     21        }
     22    }
     23
    824    /**
    925     * Test Content DataProvider
     
    1127     * array ( input_txt, converted_output_txt)
    1228     */
    13     public function get_input_output() {
     29    public function data_links_add_target() {
    1430        return array(
    1531            array(
     
    93109        );
    94110    }
    95 
    96     /**
    97      * Validate the normalize_whitespace function
    98      *
    99      * @dataProvider get_input_output
    100      */
    101     public function test_normalize_whitespace( $content, $target, $tags, $exp_str ) {
    102         if ( true === is_null( $target ) ) {
    103             $this->assertSame( $exp_str, links_add_target( $content ) );
    104         } elseif ( true === is_null( $tags ) ) {
    105             $this->assertSame( $exp_str, links_add_target( $content, $target ) );
    106         } else {
    107             $this->assertSame( $exp_str, links_add_target( $content, $target, $tags ) );
    108         }
    109     }
    110111}
  • trunk/tests/phpunit/tests/formatting/normalizeWhitespace.php

    r53562 r55562  
    66 */
    77class Tests_Formatting_NormalizeWhitespace extends WP_UnitTestCase {
     8
     9    /**
     10     * Validate the normalize_whitespace function
     11     *
     12     * @dataProvider data_normalize_whitespace
     13     */
     14    public function test_normalize_whitespace( $in_str, $exp_str ) {
     15        $this->assertSame( $exp_str, normalize_whitespace( $in_str ) );
     16    }
     17
    818    /**
    919     * WhitespaceTest Content DataProvider
     
    1121     * array( input_txt, converted_output_txt)
    1222     */
    13     public function get_input_output() {
     23    public function data_normalize_whitespace() {
    1424        return array(
    1525            array(
     
    4353        );
    4454    }
    45 
    46     /**
    47      * Validate the normalize_whitespace function
    48      *
    49      * @dataProvider get_input_output
    50      */
    51     public function test_normalize_whitespace( $in_str, $exp_str ) {
    52         $this->assertSame( $exp_str, normalize_whitespace( $in_str ) );
    53     }
    5455}
  • trunk/tests/phpunit/tests/formatting/redirect.php

    r53571 r55562  
    1919     * @ticket 44317
    2020     *
    21      * @dataProvider get_bad_status_codes
     21     * @dataProvider data_wp_redirect_bad_status_code
    2222     *
    2323     * @covers ::wp_redirect
     
    3232    }
    3333
    34     public function get_bad_status_codes() {
     34    public function data_wp_redirect_bad_status_code() {
    3535        return array(
    3636            // Tests for bad arguments.
     
    7474
    7575    /**
    76      * @dataProvider valid_url_provider
     76     * @dataProvider data_wp_validate_redirect_valid_url
    7777     *
    7878     * @covers ::wp_validate_redirect
     
    8282    }
    8383
    84     /**
    85      * @dataProvider invalid_url_provider
    86      *
    87      * @covers ::wp_validate_redirect
    88      */
    89     public function test_wp_validate_redirect_invalid_url( $url ) {
    90         $this->assertEquals( false, wp_validate_redirect( $url, false ) );
    91     }
    92 
    93     public function valid_url_provider() {
     84    public function data_wp_validate_redirect_valid_url() {
    9485        return array(
    9586            array( 'http://example.com', 'http://example.com' ),
     
    10798    }
    10899
    109     public function invalid_url_provider() {
     100    /**
     101     * @dataProvider data_wp_validate_redirect_invalid_url
     102     *
     103     * @covers ::wp_validate_redirect
     104     */
     105    public function test_wp_validate_redirect_invalid_url( $url ) {
     106        $this->assertEquals( false, wp_validate_redirect( $url, false ) );
     107    }
     108
     109    public function data_wp_validate_redirect_invalid_url() {
    110110        return array(
    111111            // parse_url() fails.
     
    177177    /**
    178178     * @ticket 47980
    179      * @dataProvider relative_url_provider
     179     * @dataProvider data_wp_validate_redirect_relative_url
    180180     *
    181181     * @covers ::wp_validate_redirect
     
    212212     * }
    213213     */
    214     public function relative_url_provider() {
     214    public function data_wp_validate_redirect_relative_url() {
    215215        return array(
    216216            array(
  • trunk/tests/phpunit/tests/formatting/sanitizeOrderby.php

    r53562 r55562  
    99
    1010    /**
    11      * @dataProvider valid_orderbys
     11     * @dataProvider data_sanitize_sql_orderby_valid
    1212     */
    13     public function test_valid( $orderby ) {
     13    public function test_sanitize_sql_orderby_valid( $orderby ) {
    1414        $this->assertSame( $orderby, sanitize_sql_orderby( $orderby ) );
    1515    }
    16     public function valid_orderbys() {
     16    public function data_sanitize_sql_orderby_valid() {
    1717        return array(
    1818            array( '1' ),
     
    3535
    3636    /**
    37      * @dataProvider invalid_orderbys
     37     * @dataProvider data_sanitize_sql_orderby_invalid
    3838     */
    39     public function test_invalid( $orderby ) {
     39    public function test_sanitize_sql_orderby_invalid( $orderby ) {
    4040        $this->assertFalse( sanitize_sql_orderby( $orderby ) );
    4141    }
    42     public function invalid_orderbys() {
     42    public function data_sanitize_sql_orderby_invalid() {
    4343        return array(
    4444            array( '' ),
  • trunk/tests/phpunit/tests/formatting/sanitizeTextField.php

    r55062 r55562  
    88 */
    99class Tests_Formatting_SanitizeTextField extends WP_UnitTestCase {
     10
     11    /**
     12     * @ticket 32257
     13     * @dataProvider data_sanitize_text_field
     14     */
     15    public function test_sanitize_text_field( $str, $expected ) {
     16        if ( is_array( $expected ) ) {
     17            $expected_oneline   = $expected['oneline'];
     18            $expected_multiline = $expected['multiline'];
     19        } else {
     20            $expected_oneline   = $expected;
     21            $expected_multiline = $expected;
     22        }
     23        $this->assertSame( $expected_oneline, sanitize_text_field( $str ) );
     24        $this->assertSameIgnoreEOL( $expected_multiline, sanitize_textarea_field( $str ) );
     25
     26    }
     27
    1028    public function data_sanitize_text_field() {
    1129        return array(
     
    127145        );
    128146    }
    129 
    130     /**
    131      * @ticket 32257
    132      * @dataProvider data_sanitize_text_field
    133      */
    134     public function test_sanitize_text_field( $str, $expected ) {
    135         if ( is_array( $expected ) ) {
    136             $expected_oneline   = $expected['oneline'];
    137             $expected_multiline = $expected['multiline'];
    138         } else {
    139             $expected_oneline   = $expected;
    140             $expected_multiline = $expected;
    141         }
    142         $this->assertSame( $expected_oneline, sanitize_text_field( $str ) );
    143         $this->assertSameIgnoreEOL( $expected_multiline, sanitize_textarea_field( $str ) );
    144 
    145     }
    146147}
  • trunk/tests/phpunit/tests/formatting/sanitizeTrackbackUrls.php

    r55064 r55562  
    99    /**
    1010     * @ticket 21624
    11      * @dataProvider separators
     11     * @dataProvider data_sanitize_trackback_urls_with_multiple_urls
    1212     */
    1313    public function test_sanitize_trackback_urls_with_multiple_urls( $separator ) {
     
    1818    }
    1919
    20     public function separators() {
     20    public function data_sanitize_trackback_urls_with_multiple_urls() {
    2121        return array(
    2222            array( "\r\n\t " ),
  • trunk/tests/phpunit/tests/formatting/seemsUtf8.php

    r53562 r55562  
    1111     * `seems_utf8` returns true for utf-8 strings, false otherwise.
    1212     *
    13      * @dataProvider utf8_strings
     13     * @dataProvider data_seems_utf8_returns_true_for_utf8_strings
    1414     */
    15     public function test_returns_true_for_utf8_strings( $utf8_string ) {
     15    public function test_seems_utf8_returns_true_for_utf8_strings( $utf8_string ) {
    1616        // From http://www.i18nguy.com/unicode-example.html
    1717        $this->assertTrue( seems_utf8( $utf8_string ) );
    1818    }
    1919
    20     public function utf8_strings() {
     20    public function data_seems_utf8_returns_true_for_utf8_strings() {
    2121        $utf8_strings = file( DIR_TESTDATA . '/formatting/utf-8/utf-8.txt' );
    2222        foreach ( $utf8_strings as &$string ) {
     
    2828
    2929    /**
    30      * @dataProvider big5_strings
     30     * @dataProvider data_seems_utf8_returns_false_for_non_utf8_strings
    3131     */
    32     public function test_returns_false_for_non_utf8_strings( $big5_string ) {
     32    public function test_seems_utf8_returns_false_for_non_utf8_strings( $big5_string ) {
    3333        $this->assertFalse( seems_utf8( $big5_string ) );
    3434    }
    3535
    36     public function big5_strings() {
     36    public function data_seems_utf8_returns_false_for_non_utf8_strings() {
    3737        // Get data from formatting/big5.txt.
    3838        $big5_strings = file( DIR_TESTDATA . '/formatting/big5.txt' );
  • trunk/tests/phpunit/tests/formatting/urlencodeDeep.php

    r53562 r55562  
    1212     * Data Provider
    1313     */
    14     public function data_test_values() {
     14    public function data_urlencode_deep() {
    1515        return array(
    1616            array( 'qwerty123456', 'qwerty123456' ),
     
    2525     * Validate the urlencode_deep function pair by pair
    2626     *
    27      * @dataProvider data_test_values
     27     * @dataProvider data_urlencode_deep
    2828     *
    2929     * @param string $actual
     
    3838     */
    3939    public function test_urlencode_deep_should_encode_all_values_in_array() {
    40         $data = $this->data_test_values();
     40        $data = $this->data_urlencode_deep();
    4141
    4242        $actual   = wp_list_pluck( $data, 0 );
  • trunk/tests/phpunit/tests/functions.php

    r55464 r55562  
    17681768     *
    17691769     * @ticket 42016
    1770      * @dataProvider data_test_validate_file
     1770     * @dataProvider data_validate_file
    17711771     *
    17721772     * @param string $file          File path.
     
    17891789     * }
    17901790     */
    1791     public function data_test_validate_file() {
     1791    public function data_validate_file() {
    17921792        return array(
    17931793
     
    19111911     * Test stream URL validation.
    19121912     *
    1913      * @dataProvider data_test_wp_is_stream
     1913     * @dataProvider data_wp_is_stream
    19141914     *
    19151915     * @param string $path     The resource path or URL.
     
    19341934     * }
    19351935     */
    1936     public function data_test_wp_is_stream() {
     1936    public function data_wp_is_stream() {
    19371937        return array(
    19381938            // Legitimate stream examples.
     
    19551955     *
    19561956     * @ticket 39667
    1957      * @dataProvider data_test_human_readable_duration
     1957     * @dataProvider data_human_readable_duration
    19581958     *
    19591959     * @param string $input    Duration.
     
    19741974     * }
    19751975     */
    1976     public function data_test_human_readable_duration() {
     1976    public function data_human_readable_duration() {
    19771977        return array(
    19781978            // Valid ii:ss cases.
     
    20312031    /**
    20322032     * @ticket 49404
    2033      * @dataProvider data_test_wp_is_json_media_type
     2033     * @dataProvider data_wp_is_json_media_type
    20342034     */
    20352035    public function test_wp_is_json_media_type( $input, $expected ) {
     
    20382038
    20392039
    2040     public function data_test_wp_is_json_media_type() {
     2040    public function data_wp_is_json_media_type() {
    20412041        return array(
    20422042            array( 'application/ld+json', true ),
  • trunk/tests/phpunit/tests/functions/doEnclose.php

    r55337 r55562  
    2929     * @since 5.3.0
    3030     *
    31      * @dataProvider data_test_do_enclose
     31     * @dataProvider data_do_enclose
    3232     */
    3333    public function test_function_with_explicit_content_input( $content, $expected ) {
     
    4545     * @since 5.3.0
    4646     *
    47      * @dataProvider data_test_do_enclose
     47     * @dataProvider data_do_enclose
    4848     */
    4949    public function test_function_with_implicit_content_input( $content, $expected ) {
     
    7373     * }
    7474     */
    75     public function data_test_do_enclose() {
     75    public function data_do_enclose() {
    7676        return array(
    7777            'null'                  => array(
     
    145145     */
    146146    public function test_function_should_delete_enclosed_link_when_no_longer_in_post_content() {
    147         $data = $this->data_test_do_enclose();
     147        $data = $this->data_do_enclose();
    148148
    149149        // Create a post with a single movie link.
     
    179179     */
    180180    public function test_function_should_support_post_object_input() {
    181         $data = $this->data_test_do_enclose();
     181        $data = $this->data_do_enclose();
    182182
    183183        $post_object = self::factory()->post->create_and_get(
     
    199199     */
    200200    public function test_function_enclosure_links_should_be_filterable() {
    201         $data = $this->data_test_do_enclose();
     201        $data = $this->data_do_enclose();
    202202
    203203        $post_id = self::factory()->post->create(
  • trunk/tests/phpunit/tests/functions/getStatusHeaderDesc.php

    r52773 r55562  
    1212
    1313    /**
    14      * @dataProvider _status_strings
     14     * @dataProvider data_get_status_header_desc
    1515     *
    1616     * @param int    $code     HTTP status code.
     
    2626     * @return array
    2727     */
    28     public function _status_strings() {
     28    public function data_get_status_header_desc() {
    2929        return array(
    3030            array( 200, 'OK' ),
  • trunk/tests/phpunit/tests/functions/isNewDay.php

    r49006 r55562  
    1212    /**
    1313     * @ticket 46627
    14      * @dataProvider _data_is_new_date
     14     * @dataProvider data_is_new_date
    1515     *
    1616     * @param string $currentday_string  The day of the current post in the loop.
     
    2727    }
    2828
    29     public function _data_is_new_date() {
     29    public function data_is_new_date() {
    3030        return array(
    3131            array( '21.05.19', '21.05.19', 0 ),
  • trunk/tests/phpunit/tests/functions/removeQueryArg.php

    r49006 r55562  
    88
    99    /**
    10      * @dataProvider remove_query_arg_provider
     10     * @dataProvider data_remove_query_arg
    1111     */
    1212    public function test_remove_query_arg( $keys_to_remove, $url, $expected ) {
     
    1717    }
    1818
    19     public function remove_query_arg_provider() {
     19    public function data_remove_query_arg() {
    2020        return array(
    2121            array( 'foo', 'edit.php?foo=test1&baz=test1', 'edit.php?baz=test1' ),
  • trunk/tests/phpunit/tests/functions/sizeFormat.php

    r54855 r55562  
    1313class Tests_Functions_SizeFormat extends WP_UnitTestCase {
    1414
    15     public function _data_size_format() {
     15    public function data_size_format() {
    1616        return array(
    1717            // Invalid values.
     
    7373
    7474    /**
    75      * @dataProvider _data_size_format
     75     * @dataProvider data_size_format
    7676     *
    7777     * @param $bytes
  • trunk/tests/phpunit/tests/functions/wpListFilter.php

    r55076 r55562  
    1010
    1111    /**
    12      * @dataProvider data_test_wp_list_filter
     12     * @dataProvider data_wp_list_filter
    1313     *
    1414     * @param array  $input_list An array of objects to filter.
     
    2222    }
    2323
    24     public function data_test_wp_list_filter() {
     24    public function data_wp_list_filter() {
    2525        return array(
    2626            'string instead of array'  => array(
  • trunk/tests/phpunit/tests/functions/wpListPluck.php

    r55341 r55562  
    205205
    206206    /**
    207      * @dataProvider data_test_wp_list_pluck
     207     * @dataProvider data_wp_list_pluck
    208208     *
    209209     * @param array      $input_list List of objects or arrays.
     
    216216    }
    217217
    218     public function data_test_wp_list_pluck() {
     218    public function data_wp_list_pluck() {
    219219        return array(
    220220            'arrays'                         => array(
  • trunk/tests/phpunit/tests/functions/wpListSort.php

    r55078 r55562  
    1010
    1111    /**
    12      * @dataProvider data_test_wp_list_sort
     12     * @dataProvider data_wp_list_sort
    1313     *
    1414     * @param string|array $orderby Either the field name to order by or an array
     
    2020    }
    2121
    22     public function data_test_wp_list_sort() {
     22    public function data_wp_list_sort() {
    2323        return array(
    2424            'single orderby ascending'        => array(
     
    335335
    336336    /**
    337      * @dataProvider data_test_wp_list_sort_preserve_keys
     337     * @dataProvider data_wp_list_sort_preserve_keys
    338338     *
    339339     * @param string|array $orderby Either the field name to order by or an array
     
    345345    }
    346346
    347     public function data_test_wp_list_sort_preserve_keys() {
     347    public function data_wp_list_sort_preserve_keys() {
    348348        return array(
    349349            'single orderby ascending'        => array(
  • trunk/tests/phpunit/tests/http/http.php

    r55370 r55562  
    1313     * @ticket 56231
    1414     *
    15      * @dataProvider make_absolute_url_testcases
     15     * @dataProvider data_make_absolute_url
    1616     *
    1717     * @covers WP_Http::make_absolute_url
     
    2222    }
    2323
    24     public function make_absolute_url_testcases() {
     24    public function data_make_absolute_url() {
    2525        // 0: The Location header, 1: The current URL, 3: The expected URL.
    2626        return array(
     
    8181
    8282    /**
    83      * @dataProvider parse_url_testcases
     83     * @dataProvider data_wp_parse_url
    8484     *
    8585     * @covers ::wp_parse_url
     
    9090    }
    9191
    92     public function parse_url_testcases() {
     92    public function data_wp_parse_url() {
    9393        // 0: The URL, 1: The expected resulting structure.
    9494        return array(
     
    218218     * @ticket 36356
    219219     *
    220      * @dataProvider parse_url_component_testcases
     220     * @dataProvider data_wp_parse_url_with_component
    221221     *
    222222     * @covers ::wp_parse_url
     
    227227    }
    228228
    229     public function parse_url_component_testcases() {
     229    public function data_wp_parse_url_with_component() {
    230230        // 0: The URL, 1: The requested component, 2: The expected resulting structure.
    231231        return array(
     
    334334     * @ticket 36356
    335335     *
    336      * @dataProvider get_component_from_parsed_url_array_testcases
     336     * @dataProvider data_get_component_from_parsed_url_array
    337337     *
    338338     * @covers ::wp_parse_url
     
    345345    }
    346346
    347     public function get_component_from_parsed_url_array_testcases() {
     347    public function data_get_component_from_parsed_url_array() {
    348348        // 0: A URL, 1: PHP URL constant, 2: The expected result.
    349349        return array(
     
    376376     * @ticket 36356
    377377     *
    378      * @dataProvider wp_translate_php_url_constant_to_key_testcases
     378     * @dataProvider data_wp_translate_php_url_constant_to_key
    379379     *
    380380     * @covers ::_wp_translate_php_url_constant_to_key
     
    385385    }
    386386
    387     public function wp_translate_php_url_constant_to_key_testcases() {
     387    public function data_wp_translate_php_url_constant_to_key() {
    388388        // 0: PHP URL constant, 1: The expected result.
    389389        return array(
  • trunk/tests/phpunit/tests/image/editor.php

    r54417 r55562  
    289289     *
    290290     * @ticket 35725
    291      * @dataProvider _test_wp_get_webp_info
     291     * @dataProvider data_wp_get_webp_info
    292292     *
    293293     */
     
    306306     * Data provider for test_wp_get_webp_info().
    307307     */
    308     public function _test_wp_get_webp_info() {
     308    public function data_wp_get_webp_info() {
    309309        return array(
    310310            // Standard JPEG.
  • trunk/tests/phpunit/tests/kses.php

    r55430 r55562  
    938938     * @ticket 55966
    939939     * @ticket 56122
    940      * @dataProvider data_test_safecss_filter_attr
     940     * @dataProvider data_safecss_filter_attr
    941941     *
    942942     * @param string $css      A string of CSS rules.
     
    957957     * }
    958958     */
    959     public function data_test_safecss_filter_attr() {
     959    public function data_safecss_filter_attr() {
    960960        return array(
    961961            // Empty input, empty output.
     
    15691569     * @ticket 37134
    15701570     *
    1571      * @dataProvider data_test_safecss_filter_attr_filtered
     1571     * @dataProvider data_safecss_filter_attr_filtered
    15721572     *
    15731573     * @param string $css      A string of CSS rules.
     
    15901590     * }
    15911591     */
    1592     public function data_test_safecss_filter_attr_filtered() {
     1592    public function data_safecss_filter_attr_filtered() {
    15931593        return array(
    15941594
  • trunk/tests/phpunit/tests/l10n/loadScriptTextdomain.php

    r54349 r55562  
    1515     * @ticket 49145
    1616     *
    17      * @dataProvider data_test_resolve_relative_path
     17     * @dataProvider data_resolve_relative_path
    1818     */
    1919    public function test_resolve_relative_path( $translation_path, $handle, $src, $textdomain, $filter = array() ) {
     
    2727    }
    2828
    29     public function data_test_resolve_relative_path() {
     29    public function data_resolve_relative_path() {
    3030        return array(
    3131            // @ticket 45528
  • trunk/tests/phpunit/tests/meta/isProtectedMeta.php

    r54896 r55562  
    88
    99    /**
    10      * @dataProvider protected_data
     10     * @dataProvider data_is_protected_meta_true
    1111     */
    12     public function test_protected( $key ) {
     12    public function test_is_protected_meta_true( $key ) {
    1313        $this->assertTrue( is_protected_meta( $key ) );
    1414    }
    1515
    16     public function protected_data() {
     16    public function data_is_protected_meta_true() {
    1717        $protected_keys = array(
    1818            array( '_wp_attachment' ),
     
    3030
    3131    /**
    32      * @dataProvider unprotected_data
     32     * @dataProvider data_is_protected_meta_false
    3333     */
    34     public function test_unprotected( $key ) {
     34    public function test_is_protected_meta_false( $key ) {
    3535        $this->assertFalse( is_protected_meta( $key ) );
    3636    }
    3737
    38     public function unprotected_data() {
     38    public function data_is_protected_meta_false() {
    3939        $unprotected_keys = array(
    4040            array( 'singleword' ),
  • trunk/tests/phpunit/tests/oembed/filterResult.php

    r52010 r55562  
    9494    }
    9595
    96     public function _data_oembed_test_strings() {
     96    public function data_wp_filter_pre_oembed_custom_result() {
    9797        return array(
    9898            array(
     
    116116
    117117    /**
    118      * @dataProvider _data_oembed_test_strings
     118     * @dataProvider data_wp_filter_pre_oembed_custom_result
    119119     */
    120120    public function test_wp_filter_pre_oembed_custom_result( $html, $expected ) {
  • trunk/tests/phpunit/tests/option/sanitizeOption.php

    r54229 r55562  
    77
    88    /**
     9     * @dataProvider data_sanitize_option
     10     *
     11     * @covers ::sanitize_option
     12     */
     13    public function test_sanitize_option( $option_name, $sanitized, $original ) {
     14        $this->assertSame( $sanitized, sanitize_option( $option_name, $original ) );
     15    }
     16    /**
    917     * Data provider to test all of the sanitize_option() case
    1018     *
     
    1321     * @return array
    1422     */
    15     public function sanitize_option_provider() {
     23    public function data_sanitize_option() {
    1624        return array(
    1725            array( 'admin_email', 'mail@example.com', 'mail@example.com' ),
     
    8795
    8896    /**
    89      * @dataProvider sanitize_option_provider
     97     * @dataProvider data_sanitize_option_upload_path
    9098     *
    9199     * @covers ::sanitize_option
    92100     */
    93     public function test_sanitize_option( $option_name, $sanitized, $original ) {
    94         $this->assertSame( $sanitized, sanitize_option( $option_name, $original ) );
     101    public function test_sanitize_option_upload_path( $provided, $expected ) {
     102        $this->assertSame( $expected, sanitize_option( 'upload_path', $provided ) );
    95103    }
    96104
    97     public function upload_path_provider() {
     105    public function data_sanitize_option_upload_path() {
    98106        return array(
    99107            array( '<a href="http://www.example.com">Link</a>', 'Link' ),
     
    102110            array( '\path\to\things', '\path\to\things' ),
    103111        );
    104     }
    105 
    106     /**
    107      * @dataProvider upload_path_provider
    108      *
    109      * @covers ::sanitize_option
    110      */
    111     public function test_sanitize_option_upload_path( $provided, $expected ) {
    112         $this->assertSame( $expected, sanitize_option( 'upload_path', $provided ) );
    113112    }
    114113
     
    134133
    135134    /**
    136      * @dataProvider permalink_structure_provider
     135     * @dataProvider data_sanitize_option_permalink_structure
    137136     *
    138137     * @covers ::sanitize_option
    139138     * @covers ::get_settings_errors
    140139     */
    141     public function test_sanitize_permalink_structure( $provided, $expected, $valid ) {
     140    public function test_sanitize_option_permalink_structure( $provided, $expected, $valid ) {
    142141        global $wp_settings_errors;
    143142
     
    160159    }
    161160
    162     public function permalink_structure_provider() {
     161    public function data_sanitize_option_permalink_structure() {
    163162        return array(
    164163            array( '', '', true ),
  • trunk/tests/phpunit/tests/pomo/pluralForms.php

    r48999 r55562  
    4040    /**
    4141     * @ticket 41562
     42     * @dataProvider data_locales
    4243     * @group external-http
    4344     */
    44     public function test_locales_provider() {
    45         $locales = self::locales_provider();
     45    public function test_regression( $lang, $nplurals, $expression ) {
     46        require_once dirname( dirname( __DIR__ ) ) . '/includes/plural-form-function.php';
     47
     48        $parenthesized = self::parenthesize_plural_expression( $expression );
     49        $old_style     = tests_make_plural_form_function( $nplurals, $parenthesized );
     50        $plural_forms  = new Plural_Forms( $expression );
     51
     52        $generated_old = array();
     53        $generated_new = array();
     54
     55        foreach ( range( 0, 200 ) as $i ) {
     56            $generated_old[] = $old_style( $i );
     57            $generated_new[] = $plural_forms->get( $i );
     58        }
     59
     60        $this->assertSame( $generated_old, $generated_new );
     61    }
     62
     63    /**
     64     * @ticket 41562
     65     * @group external-http
     66     */
     67    public function test_locales_file_not_empty() {
     68        $locales = self::data_locales();
    4669
    4770        $this->assertNotEmpty( $locales, 'Unable to retrieve GP_Locales file' );
    4871    }
    4972
    50     public static function locales_provider() {
     73    public static function data_locales() {
    5174        if ( ! class_exists( 'GP_Locales' ) ) {
    5275            $filename = download_url( 'https://raw.githubusercontent.com/GlotPress/GlotPress-WP/develop/locales/locales.php' );
     
    7194    /**
    7295     * @ticket 41562
    73      * @dataProvider locales_provider
    74      * @group external-http
    75      */
    76     public function test_regression( $lang, $nplurals, $expression ) {
    77         require_once dirname( dirname( __DIR__ ) ) . '/includes/plural-form-function.php';
    78 
    79         $parenthesized = self::parenthesize_plural_expression( $expression );
    80         $old_style     = tests_make_plural_form_function( $nplurals, $parenthesized );
    81         $plural_forms  = new Plural_Forms( $expression );
    82 
    83         $generated_old = array();
    84         $generated_new = array();
    85 
    86         foreach ( range( 0, 200 ) as $i ) {
    87             $generated_old[] = $old_style( $i );
    88             $generated_new[] = $plural_forms->get( $i );
    89         }
    90 
    91         $this->assertSame( $generated_old, $generated_new );
    92     }
    93 
    94     public static function simple_provider() {
     96     * @dataProvider data_simple
     97     */
     98    public function test_simple( $expression, $expected ) {
     99        $plural_forms = new Plural_Forms( $expression );
     100        $actual       = array();
     101        foreach ( array_keys( $expected ) as $num ) {
     102            $actual[ $num ] = $plural_forms->get( $num );
     103        }
     104
     105        $this->assertSame( $expected, $actual );
     106    }
     107
     108    public static function data_simple() {
    95109        return array(
    96110            array(
     
    144158
    145159    /**
    146      * @ticket 41562
    147      * @dataProvider simple_provider
    148      */
    149     public function test_simple( $expression, $expected ) {
     160     * Ensures that an exception is thrown when an invalid plural form is encountered.
     161     *
     162     * @ticket 41562
     163     * @dataProvider data_exceptions
     164     */
     165    public function test_exceptions( $expression, $expected_message, $call_get ) {
     166        $this->expectException( 'Exception' );
     167        $this->expectExceptionMessage( $expected_message );
     168
    150169        $plural_forms = new Plural_Forms( $expression );
    151         $actual       = array();
    152         foreach ( array_keys( $expected ) as $num ) {
    153             $actual[ $num ] = $plural_forms->get( $num );
    154         }
    155 
    156         $this->assertSame( $expected, $actual );
     170        if ( $call_get ) {
     171            $plural_forms->get( 1 );
     172        }
    157173    }
    158174
     
    195211            ),
    196212        );
    197     }
    198 
    199     /**
    200      * Ensures that an exception is thrown when an invalid plural form is encountered.
    201      *
    202      * @ticket 41562
    203      * @dataProvider data_exceptions
    204      */
    205     public function test_exceptions( $expression, $expected_message, $call_get ) {
    206         $this->expectException( 'Exception' );
    207         $this->expectExceptionMessage( $expected_message );
    208 
    209         $plural_forms = new Plural_Forms( $expression );
    210         if ( $call_get ) {
    211             $plural_forms->get( 1 );
    212         }
    213213    }
    214214
  • trunk/tests/phpunit/tests/post/nav-menu.php

    r55035 r55562  
    967967
    968968    /**
     969     * @ticket 43401
     970     * @dataProvider data_iri_current_menu_item
     971     */
     972    public function test_iri_current_menu_item( $custom_link, $current = true ) {
     973        wp_update_nav_menu_item(
     974            $this->menu_id,
     975            0,
     976            array(
     977                'menu-item-status' => 'publish',
     978                'menu-item-type'   => 'custom',
     979                'menu-item-url'    => $custom_link,
     980            )
     981        );
     982
     983        $this->go_to( site_url( '/%D0%BF%D1%80%D0%B8%D0%B2%D0%B5%D1%82/' ) );
     984
     985        $menu_items = wp_get_nav_menu_items( $this->menu_id );
     986        _wp_menu_item_classes_by_context( $menu_items );
     987
     988        $classes = $menu_items[0]->classes;
     989
     990        if ( $current ) {
     991            $this->assertContains( 'current-menu-item', $classes );
     992        } else {
     993            $this->assertNotContains( 'current-menu-item', $classes );
     994        }
     995    }
     996
     997    /**
    969998     * Provides IRI matching data for _wp_menu_item_classes_by_context() test.
    970999     */
    971     public function get_iri_current_menu_items() {
     1000    public function data_iri_current_menu_item() {
    9721001        return array(
    9731002            array( site_url( '/%D0%BF%D1%80%D0%B8%D0%B2%D0%B5%D1%82/' ) ),
     
    9811010
    9821011    /**
    983      * @ticket 43401
    984      * @dataProvider get_iri_current_menu_items
    985      */
    986     public function test_iri_current_menu_item( $custom_link, $current = true ) {
    987         wp_update_nav_menu_item(
    988             $this->menu_id,
    989             0,
    990             array(
    991                 'menu-item-status' => 'publish',
    992                 'menu-item-type'   => 'custom',
    993                 'menu-item-url'    => $custom_link,
    994             )
    995         );
    996 
    997         $this->go_to( site_url( '/%D0%BF%D1%80%D0%B8%D0%B2%D0%B5%D1%82/' ) );
    998 
    999         $menu_items = wp_get_nav_menu_items( $this->menu_id );
    1000         _wp_menu_item_classes_by_context( $menu_items );
    1001 
    1002         $classes = $menu_items[0]->classes;
    1003 
    1004         if ( $current ) {
    1005             $this->assertContains( 'current-menu-item', $classes );
    1006         } else {
    1007             $this->assertNotContains( 'current-menu-item', $classes );
    1008         }
    1009     }
    1010 
    1011     /**
    10121012     * @ticket 44005
    10131013     * @group privacy
  • trunk/tests/phpunit/tests/post/query.php

    r53942 r55562  
    713713    }
    714714
    715     public function set_found_posts_provider() {
     715    /**
     716     * @ticket 42860
     717     *
     718     * @dataProvider data_set_found_posts_not_posts_as_an_array
     719     */
     720    public function test_set_found_posts_not_posts_as_an_array( $posts, $expected ) {
     721        $q = new WP_Query(
     722            array(
     723                'post_type'      => 'wptests_pt',
     724                'posts_per_page' => 1,
     725            )
     726        );
     727
     728        $q->posts = $posts;
     729
     730        $methd = new ReflectionMethod( 'WP_Query', 'set_found_posts' );
     731        $methd->setAccessible( true );
     732        $methd->invoke( $q, array( 'no_found_rows' => false ), array() );
     733
     734        $this->assertSame( $expected, $q->found_posts );
     735    }
     736
     737    public function data_set_found_posts_not_posts_as_an_array() {
    716738        // Count return 0 for null, but 1 for other data you may not expect.
    717739        return array(
     
    724746
    725747    /**
    726      * @ticket 42860
    727      *
    728      * @dataProvider set_found_posts_provider
    729      */
    730     public function test_set_found_posts_not_posts_as_an_array( $posts, $expected ) {
    731         $q = new WP_Query(
    732             array(
    733                 'post_type'      => 'wptests_pt',
    734                 'posts_per_page' => 1,
    735             )
    736         );
    737 
    738         $q->posts = $posts;
    739 
    740         $methd = new ReflectionMethod( 'WP_Query', 'set_found_posts' );
    741         $methd->setAccessible( true );
    742         $methd->invoke( $q, array( 'no_found_rows' => false ), array() );
    743 
    744         $this->assertSame( $expected, $q->found_posts );
    745     }
    746 
    747     /**
    748748     * @ticket 42469
    749749     */
  • trunk/tests/phpunit/tests/post/wpUniquePostSlug.php

    r52010 r55562  
    129129
    130130    /**
    131      * @dataProvider allowed_post_statuses
     131     * @dataProvider data_allowed_post_statuses_should_not_be_forced_to_be_unique
    132132     */
    133133    public function test_allowed_post_statuses_should_not_be_forced_to_be_unique( $status ) {
     
    150150    }
    151151
    152     public function allowed_post_statuses() {
     152    public function data_allowed_post_statuses_should_not_be_forced_to_be_unique() {
    153153        return array(
    154154            array( 'draft' ),
  • trunk/tests/phpunit/tests/rest-api.php

    r55116 r55562  
    2626        remove_filter( 'wp_rest_server_class', array( $this, 'filter_wp_rest_server_class' ) );
    2727        parent::tear_down();
     28    }
     29
     30    public function filter_wp_rest_server_class( $class_name ) {
     31        return 'Spy_REST_Server';
    2832    }
    2933
     
    823827    }
    824828
    825     public function jsonp_callback_provider() {
     829    /**
     830     * @dataProvider data_jsonp_callback_check
     831     */
     832    public function test_jsonp_callback_check( $callback, $expected ) {
     833        $this->assertSame( $expected, wp_check_jsonp_callback( $callback ) );
     834    }
     835
     836    public function data_jsonp_callback_check() {
    826837        return array(
    827838            // Standard names.
     
    842853
    843854    /**
    844      * @dataProvider jsonp_callback_provider
    845      */
    846     public function test_jsonp_callback_check( $callback, $expected ) {
    847         $this->assertSame( $expected, wp_check_jsonp_callback( $callback ) );
    848     }
    849 
    850     public function rest_date_provider() {
     855     * @dataProvider data_rest_parse_date
     856     */
     857    public function test_rest_parse_date( $date, $expected ) {
     858        $this->assertEquals( $expected, rest_parse_date( $date ) );
     859    }
     860
     861    public function data_rest_parse_date() {
    851862        return array(
    852863            // Valid dates with timezones.
     
    874885
    875886    /**
    876      * @dataProvider rest_date_provider
    877      */
    878     public function test_rest_parse_date( $date, $expected ) {
    879         $this->assertEquals( $expected, rest_parse_date( $date ) );
    880     }
    881 
    882     public function rest_date_force_utc_provider() {
     887     * @dataProvider data_rest_parse_date_force_utc
     888     */
     889    public function test_rest_parse_date_force_utc( $date, $expected ) {
     890        $this->assertSame( $expected, rest_parse_date( $date, true ) );
     891    }
     892
     893    public function data_rest_parse_date_force_utc() {
    883894        return array(
    884895            // Valid dates with timezones.
     
    903914            array( '2017', false ),
    904915        );
    905     }
    906 
    907     /**
    908      * @dataProvider rest_date_force_utc_provider
    909      */
    910     public function test_rest_parse_date_force_utc( $date, $expected ) {
    911         $this->assertSame( $expected, rest_parse_date( $date, true ) );
    912     }
    913 
    914     public function filter_wp_rest_server_class( $class_name ) {
    915         return 'Spy_REST_Server';
    916916    }
    917917
     
    17841784
    17851785    /**
    1786      * @dataProvider rest_ensure_response_data_provider
     1786     * @dataProvider data_rest_ensure_response_returns_instance_of_wp_rest_response
    17871787     *
    17881788     * @param mixed $response      The response passed to rest_ensure_response().
     
    18001800     * @return array
    18011801     */
    1802     public function rest_ensure_response_data_provider() {
     1802    public function data_rest_ensure_response_returns_instance_of_wp_rest_response() {
    18031803        return array(
    18041804            array( null, null ),
  • trunk/tests/phpunit/tests/rest-api/rest-attachments-controller.php

    r55457 r55562  
    136136    }
    137137
    138     public static function disposition_provider() {
     138    /**
     139     * @dataProvider data_parse_disposition
     140     */
     141    public function test_parse_disposition( $header, $expected ) {
     142        $header_list = array( $header );
     143        $parsed      = WP_REST_Attachments_Controller::get_filename_from_disposition( $header_list );
     144        $this->assertSame( $expected, $parsed );
     145    }
     146
     147    public static function data_parse_disposition() {
    139148        return array(
    140149            // Types.
     
    166175            array( 'unknown; notfilename="foo.jpg"', null ),
    167176        );
    168     }
    169 
    170     /**
    171      * @dataProvider disposition_provider
    172      */
    173     public function test_parse_disposition( $header, $expected ) {
    174         $header_list = array( $header );
    175         $parsed      = WP_REST_Attachments_Controller::get_filename_from_disposition( $header_list );
    176         $this->assertSame( $expected, $parsed );
    177177    }
    178178
     
    12581258    }
    12591259
    1260     public static function attachment_roundtrip_provider() {
     1260    /**
     1261     * @dataProvider data_attachment_roundtrip_as_author
     1262     * @requires function imagejpeg
     1263     */
     1264    public function test_attachment_roundtrip_as_author( $raw, $expected ) {
     1265        wp_set_current_user( self::$author_id );
     1266        $this->assertFalse( current_user_can( 'unfiltered_html' ) );
     1267        $this->verify_attachment_roundtrip( $raw, $expected );
     1268    }
     1269
     1270    public static function data_attachment_roundtrip_as_author() {
    12611271        return array(
    12621272            array(
     
    13531363            ),
    13541364        );
    1355     }
    1356 
    1357     /**
    1358      * @dataProvider attachment_roundtrip_provider
    1359      * @requires function imagejpeg
    1360      */
    1361     public function test_post_roundtrip_as_author( $raw, $expected ) {
    1362         wp_set_current_user( self::$author_id );
    1363         $this->assertFalse( current_user_can( 'unfiltered_html' ) );
    1364         $this->verify_attachment_roundtrip( $raw, $expected );
    13651365    }
    13661366
  • trunk/tests/phpunit/tests/rest-api/rest-comments-controller.php

    r55457 r55562  
    11451145    }
    11461146
    1147     public function comment_dates_provider() {
     1147    public function data_comment_dates() {
    11481148        return array(
    11491149            'set date without timezone'     => array(
     
    11911191
    11921192    /**
    1193      * @dataProvider comment_dates_provider
     1193     * @dataProvider data_comment_dates
    11941194     */
    11951195    public function test_create_comment_date( $params, $results ) {
     
    23392339
    23402340    /**
    2341      * @dataProvider comment_dates_provider
     2341     * @dataProvider data_comment_dates
    23422342     */
    23432343    public function test_update_comment_date( $params, $results ) {
  • trunk/tests/phpunit/tests/rest-api/rest-post-meta-fields.php

    r55457 r55562  
    20542054     * @ticket 43392
    20552055     * @ticket 48363
    2056      * @dataProvider _dp_meta_values_are_not_set_to_null_in_response_if_type_safely_serializable
     2056     * @dataProvider data_meta_values_are_not_set_to_null_in_response_if_type_safely_serializable
    20572057     */
    20582058    public function test_meta_values_are_not_set_to_null_in_response_if_type_safely_serializable( $type, $stored, $expected ) {
     
    20752075    }
    20762076
    2077     public function _dp_meta_values_are_not_set_to_null_in_response_if_type_safely_serializable() {
     2077    public function data_meta_values_are_not_set_to_null_in_response_if_type_safely_serializable() {
    20782078        return array(
    20792079            array( 'boolean', 'true', true ),
  • trunk/tests/phpunit/tests/rest-api/rest-posts-controller.php

    r55457 r55562  
    23582358    }
    23592359
    2360     public function post_dates_provider() {
     2360    public function data_post_dates() {
    23612361        $all_statuses = array(
    23622362            'draft',
     
    24292429
    24302430    /**
    2431      * @dataProvider post_dates_provider
     2431     * @dataProvider data_post_dates
    24322432     */
    24332433    public function test_create_post_date( $status, $params, $results ) {
     
    34783478
    34793479    /**
    3480      * @dataProvider post_dates_provider
     3480     * @dataProvider data_post_dates
    34813481     */
    34823482    public function test_update_post_date( $status, $params, $results ) {
     
    40334033    }
    40344034
    4035     public static function post_roundtrip_provider() {
     4035    /**
     4036     * @dataProvider data_post_roundtrip_as_author
     4037     */
     4038    public function test_post_roundtrip_as_author( $raw, $expected ) {
     4039        wp_set_current_user( self::$author_id );
     4040
     4041        $this->assertFalse( current_user_can( 'unfiltered_html' ) );
     4042        $this->verify_post_roundtrip( $raw, $expected );
     4043    }
     4044
     4045    public static function data_post_roundtrip_as_author() {
    40364046        return array(
    40374047            array(
     
    41284138            ),
    41294139        );
    4130     }
    4131 
    4132     /**
    4133      * @dataProvider post_roundtrip_provider
    4134      */
    4135     public function test_post_roundtrip_as_author( $raw, $expected ) {
    4136         wp_set_current_user( self::$author_id );
    4137 
    4138         $this->assertFalse( current_user_can( 'unfiltered_html' ) );
    4139         $this->verify_post_roundtrip( $raw, $expected );
    41404140    }
    41414141
  • trunk/tests/phpunit/tests/rest-api/rest-request.php

    r55457 r55562  
    5858    }
    5959
    60     public static function header_provider() {
     60    /**
     61     * @dataProvider data_header_canonicalization
     62     * @param string $original Original header key.
     63     * @param string $expected Expected canonicalized version.
     64     */
     65    public function test_header_canonicalization( $original, $expected ) {
     66        $this->assertSame( $expected, $this->request->canonicalize_header_name( $original ) );
     67    }
     68
     69    public static function data_header_canonicalization() {
    6170        return array(
    6271            array( 'Test', 'test' ),
     
    7079
    7180    /**
    72      * @dataProvider header_provider
    73      * @param string $original Original header key.
    74      * @param string $expected Expected canonicalized version.
    75      */
    76     public function test_header_canonicalization( $original, $expected ) {
    77         $this->assertSame( $expected, $this->request->canonicalize_header_name( $original ) );
    78     }
    79 
    80     public static function content_type_provider() {
    81         return array(
    82             // Check basic parsing.
    83             array( 'application/x-wp-example', 'application/x-wp-example', 'application', 'x-wp-example', '' ),
    84             array( 'application/x-wp-example; charset=utf-8', 'application/x-wp-example', 'application', 'x-wp-example', 'charset=utf-8' ),
    85 
    86             // Check case insensitivity.
    87             array( 'APPLICATION/x-WP-Example', 'application/x-wp-example', 'application', 'x-wp-example', '' ),
    88         );
    89     }
    90 
    91     /**
    92      * @dataProvider content_type_provider
     81     * @dataProvider data_content_type_parsing
    9382     *
    9483     * @param string $header     Header value.
     
    111100    }
    112101
     102    public static function data_content_type_parsing() {
     103        return array(
     104            // Check basic parsing.
     105            array( 'application/x-wp-example', 'application/x-wp-example', 'application', 'x-wp-example', '' ),
     106            array( 'application/x-wp-example; charset=utf-8', 'application/x-wp-example', 'application', 'x-wp-example', 'charset=utf-8' ),
     107
     108            // Check case insensitivity.
     109            array( 'APPLICATION/x-WP-Example', 'application/x-wp-example', 'application', 'x-wp-example', '' ),
     110        );
     111    }
     112
    113113    protected function request_with_parameters() {
    114114        $this->request->set_url_params(
     
    187187    }
    188188
    189     public static function alternate_json_content_type_provider() {
     189    /**
     190     * @ticket 49404
     191     * @dataProvider data_alternate_json_content_type
     192     *
     193     * @param string $content_type The Content-Type header.
     194     * @param string $source       The source value.
     195     * @param bool   $accept_json  The accept_json value.
     196     */
     197    public function test_alternate_json_content_type( $content_type, $source, $accept_json ) {
     198        $this->request_with_parameters();
     199
     200        $this->request->set_method( 'POST' );
     201        $this->request->set_header( 'Content-Type', $content_type );
     202        $this->request->set_attributes( array( 'accept_json' => true ) );
     203
     204        // Check that JSON takes precedence.
     205        $this->assertSame( $source, $this->request->get_param( 'source' ) );
     206        $this->assertEquals( $accept_json, $this->request->get_param( 'has_json_params' ) );
     207    }
     208
     209    public static function data_alternate_json_content_type() {
    190210        return array(
    191211            array( 'application/ld+json', 'json', true ),
     
    200220    /**
    201221     * @ticket 49404
    202      * @dataProvider alternate_json_content_type_provider
     222     * @dataProvider data_is_json_content_type
    203223     *
    204224     * @param string $content_type The Content-Type header.
    205      * @param string $source       The source value.
    206      * @param bool   $accept_json  The accept_json value.
    207      */
    208     public function test_alternate_json_content_type( $content_type, $source, $accept_json ) {
     225     * @param bool   $is_json      The is_json value.
     226     */
     227    public function test_is_json_content_type( $content_type, $is_json ) {
    209228        $this->request_with_parameters();
    210229
    211         $this->request->set_method( 'POST' );
    212230        $this->request->set_header( 'Content-Type', $content_type );
    213         $this->request->set_attributes( array( 'accept_json' => true ) );
    214 
    215         // Check that JSON takes precedence.
    216         $this->assertSame( $source, $this->request->get_param( 'source' ) );
    217         $this->assertEquals( $accept_json, $this->request->get_param( 'has_json_params' ) );
    218     }
    219 
    220     public static function is_json_content_type_provider() {
     231
     232        // Check for JSON Content-Type.
     233        $this->assertSame( $is_json, $this->request->is_json_content_type() );
     234    }
     235
     236    public static function data_is_json_content_type() {
    221237        return array(
    222238            array( 'application/ld+json', true ),
     
    231247    /**
    232248     * @ticket 49404
    233      * @dataProvider is_json_content_type_provider
    234      *
    235      * @param string $content_type The Content-Type header.
    236      * @param bool   $is_json      The is_json value.
    237      */
    238     public function test_is_json_content_type( $content_type, $is_json ) {
    239         $this->request_with_parameters();
    240 
    241         $this->request->set_header( 'Content-Type', $content_type );
    242 
    243         // Check for JSON Content-Type.
    244         $this->assertSame( $is_json, $this->request->is_json_content_type() );
    245     }
    246 
    247     /**
    248      * @ticket 49404
    249249     */
    250250    public function test_content_type_cache() {
     
    311311    }
    312312
    313     public function non_post_http_methods_with_request_body_provider() {
    314         return array(
    315             array( 'PUT' ),
    316             array( 'PATCH' ),
    317             array( 'DELETE' ),
    318         );
    319     }
    320 
    321313    /**
    322314     * Tests that methods supporting request bodies have access to the
     
    324316     * other methods `WP_REST_Request` needs to parse the body for us.
    325317     *
    326      * @dataProvider non_post_http_methods_with_request_body_provider
     318     * @dataProvider data_non_post_body_parameters
    327319     */
    328320    public function test_non_post_body_parameters( $request_method ) {
     
    346338    }
    347339
     340    public function data_non_post_body_parameters() {
     341        return array(
     342            array( 'PUT' ),
     343            array( 'PATCH' ),
     344            array( 'DELETE' ),
     345        );
     346    }
     347
    348348    public function test_parameters_for_json_put() {
    349349        $data = array(
  • trunk/tests/phpunit/tests/rest-api/rest-server.php

    r55457 r55562  
    5050    }
    5151
     52    public function filter_wp_rest_server_class() {
     53        return 'Spy_REST_Server';
     54    }
     55
    5256    public function test_envelope() {
    5357        $data    = array(
     
    10051009
    10061010    /**
    1007      * @dataProvider _dp_response_to_data_embedding
     1011     * @dataProvider data_response_to_data_embedding
    10081012     */
    10091013    public function test_response_to_data_embedding( $expected, $embed ) {
     
    10231027    }
    10241028
    1025     public function _dp_response_to_data_embedding() {
     1029    public function data_response_to_data_embedding() {
    10261030        return array(
    10271031            array(
     
    14601464        $result = rest_get_server()->serve_request( '/test/data\\with\\slashes' );
    14611465        $this->assertSame( 'data\\with\\slashes', rest_get_server()->last_request->get_header( 'x_my_header' ) );
    1462     }
    1463 
    1464     public function filter_wp_rest_server_class() {
    1465         return 'Spy_REST_Server';
    14661466    }
    14671467
  • trunk/tests/phpunit/tests/rest-api/wpRestTemplatesController.php

    r55457 r55562  
    170170    /**
    171171     * @ticket 54507
    172      * @dataProvider get_template_endpoint_urls
     172     * @dataProvider data_get_item_works_with_a_single_slash
    173173     */
    174174    public function test_get_item_works_with_a_single_slash( $endpoint_url ) {
     
    204204    }
    205205
    206     public function get_template_endpoint_urls() {
     206    public function data_get_item_works_with_a_single_slash() {
    207207        return array(
    208208            array( '/wp/v2/templates/default/my_template' ),
     
    376376    /**
    377377     * @ticket 54507
    378      * @dataProvider get_template_ids_to_sanitize
     378     * @dataProvider data_sanitize_template_id
    379379     */
    380380    public function test_sanitize_template_id( $input_id, $sanitized_id ) {
     
    386386    }
    387387
    388     public function get_template_ids_to_sanitize() {
     388    public function data_sanitize_template_id() {
    389389        return array(
    390390            array( 'tt1-blocks/index', 'tt1-blocks//index' ),
  • trunk/tests/phpunit/tests/rewrite/rewriteTags.php

    r51568 r55562  
    2121    }
    2222
    23     public function _invalid_rewrite_tags() {
    24         return array(
    25             array( 'foo', 'bar' ),
    26             array( '%', 'bar' ),
    27             array( '%a', 'bar' ),
    28             array( 'a%', 'bar' ),
    29             array( '%%', 'bar' ),
    30             array( '', 'bar' ),
    31         );
    32     }
    33 
    3423    /**
    35      * @dataProvider _invalid_rewrite_tags
     24     * @dataProvider data_add_rewrite_tag_invalid
    3625     *
    3726     * @param string $tag   Rewrite tag.
     
    4534        $this->assertSameSets( $this->rewritereplace, $wp_rewrite->rewritereplace );
    4635        $this->assertSameSets( $this->queryreplace, $wp_rewrite->queryreplace );
     36    }
     37
     38    public function data_add_rewrite_tag_invalid() {
     39        return array(
     40            array( 'foo', 'bar' ),
     41            array( '%', 'bar' ),
     42            array( '%a', 'bar' ),
     43            array( 'a%', 'bar' ),
     44            array( '%%', 'bar' ),
     45            array( '', 'bar' ),
     46        );
    4747    }
    4848
  • trunk/tests/phpunit/tests/shortcode.php

    r55119 r55562  
    405405    }
    406406
    407     public function data_test_strip_shortcodes() {
     407    /**
     408     * @ticket 10326
     409     *
     410     * @dataProvider data_strip_shortcodes
     411     *
     412     * @param string $expected  Expected output.
     413     * @param string $content   Content to run strip_shortcodes() on.
     414     */
     415    public function test_strip_shortcodes( $expected, $content ) {
     416        $this->assertSame( $expected, strip_shortcodes( $content ) );
     417    }
     418
     419    public function data_strip_shortcodes() {
    408420        return array(
    409421            array( 'before', 'before[gallery]' ),
     
    421433
    422434    /**
    423      * @ticket 10326
    424      *
    425      * @dataProvider data_test_strip_shortcodes
    426      *
    427      * @param string $expected  Expected output.
    428      * @param string $content   Content to run strip_shortcodes() on.
    429      */
    430     public function test_strip_shortcodes( $expected, $content ) {
    431         $this->assertSame( $expected, strip_shortcodes( $content ) );
    432     }
    433 
    434     /**
    435435     * @ticket 37767
    436436     */
  • trunk/tests/phpunit/tests/sitemaps/functions.php

    r52010 r55562  
    6464     * Test get_sitemap_url() with plain permalinks.
    6565     *
    66      * @dataProvider plain_permalinks_provider
     66     * @dataProvider data_get_sitemap_url_plain_permalinks
    6767     */
    6868    public function test_get_sitemap_url_plain_permalinks( $name, $subtype_name, $page, $expected ) {
     
    7575     * Test get_sitemap_url() with pretty permalinks.
    7676     *
    77      * @dataProvider pretty_permalinks_provider
     77     * @dataProvider data_get_sitemap_url_pretty_permalinks
    7878     */
    7979    public function test_get_sitemap_url_pretty_permalinks( $name, $subtype_name, $page, $expected ) {
     
    9797     * }
    9898     */
    99     public function plain_permalinks_provider() {
     99    public function data_get_sitemap_url_plain_permalinks() {
    100100        return array(
    101101            array( 'posts', 'post', 1, home_url( '/?sitemap=posts&sitemap-subtype=post&paged=1' ) ),
     
    129129     * }
    130130     */
    131     public function pretty_permalinks_provider() {
     131    public function data_get_sitemap_url_pretty_permalinks() {
    132132        return array(
    133133            array( 'posts', 'post', 1, home_url( '/wp-sitemap-posts-post-1.xml' ) ),
  • trunk/tests/phpunit/tests/term/wpGenerateTagCloud.php

    r53687 r55562  
    99     * Testing when passed $tags array is empty
    1010     *
    11      * @dataProvider empty_tags_data_provider
     11     * @dataProvider data_empty_tags
    1212     *
    1313     * @param $expected Expected output from `wp_generate_tag_cloud()`.
     
    2222     * Testing when no tags are found
    2323     *
    24      * @dataProvider empty_tags_data_provider
     24     * @dataProvider data_empty_tags
    2525     *
    2626     * @param $expected Expected output from `wp_generate_tag_cloud()`.
     
    4242     * @return array
    4343     */
    44     public function empty_tags_data_provider() {
     44    public function data_empty_tags() {
    4545        return array(
    4646            // When 'format' => 'array', we should be getting an empty array back.
  • trunk/tests/phpunit/tests/user/capabilities.php

    r54865 r55562  
    13151315    }
    13161316
    1317     public function authorless_post_statuses() {
    1318         return array( array( 'draft' ), array( 'private' ), array( 'publish' ) );
    1319     }
    1320 
    13211317    /**
    13221318     * @ticket 27020
    1323      * @dataProvider authorless_post_statuses
     1319     * @dataProvider data_authorless_post
    13241320     */
    13251321    public function test_authorless_post( $status ) {
     
    13481344        $this->assertFalse( $contributor->has_cap( 'delete_post', $post ) );
    13491345        $this->assertSame( 'publish' === $status, $contributor->has_cap( 'read_post', $post ) );
     1346    }
     1347
     1348    public function data_authorless_post() {
     1349        return array( array( 'draft' ), array( 'private' ), array( 'publish' ) );
    13501350    }
    13511351
  • trunk/tests/phpunit/tests/user/query.php

    r54889 r55562  
    187187
    188188    /**
    189      * @dataProvider orderby_should_convert_non_prefixed_keys_data
     189     * @dataProvider data_orderby_should_convert_non_prefixed_keys
    190190     */
    191191    public function test_orderby_should_convert_non_prefixed_keys( $short_key, $full_key ) {
     
    199199    }
    200200
    201     public function orderby_should_convert_non_prefixed_keys_data() {
     201    public function data_orderby_should_convert_non_prefixed_keys() {
    202202        return array(
    203203            array( 'nicename', 'user_nicename' ),
Note: See TracChangeset for help on using the changeset viewer.