Make WordPress Core


Ignore:
Timestamp:
11/04/2021 03:22:47 PM (3 years ago)
Author:
hellofromTonya
Message:

Coding Standards: Add visibility to methods in tests/phpunit/tests/.

Adds a public visibility to test fixtures, tests, data providers, and callbacks methods.

Adds a private visibility to helper methods within test classes.

Renames callbacks and helpers that previously started with a _ prefix. Why? For consistency and to leverage using the method visibility. Further naming standardizations is beyond the scope of this commit.

Props costdev, jrf, hellofromTonya.
Fixes #54177.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/kses.php

    r51963 r52010  
    1515     * @param string $expect_string Expected result after passing through kses.
    1616     */
    17     function test_wp_filter_post_kses_address( $string, $expect_string ) {
     17    public function test_wp_filter_post_kses_address( $string, $expect_string ) {
    1818        global $allowedposttags;
    1919
     
    2929     * }
    3030     */
    31     function data_wp_filter_post_kses_address() {
     31    public function data_wp_filter_post_kses_address() {
    3232        $attributes = array(
    3333            'class' => 'classname',
     
    6464     * @return void
    6565     */
    66     function test_wp_filter_post_kses_a( $string, $expect_string ) {
     66    public function test_wp_filter_post_kses_a( $string, $expect_string ) {
    6767        global $allowedposttags;
    6868
     
    7878     * }
    7979     */
    80     function data_wp_filter_post_kses_a() {
     80    public function data_wp_filter_post_kses_a() {
    8181        $attributes = array(
    8282            'class'    => 'classname',
     
    121121     * @param string $expected Expected output following KSES parsing.
    122122     */
    123     function test_wp_kses_video( $source, $context, $expected ) {
     123    public function test_wp_kses_video( $source, $context, $expected ) {
    124124        $actual = wp_kses( $source, $context );
    125125        $this->assertSame( $expected, $actual );
     
    135135     * }
    136136     */
    137     function data_wp_kses_video() {
     137    public function data_wp_kses_video() {
    138138        return array(
    139139            // Set 0: Valid post object params in post context.
     
    172172     * @return void
    173173     */
    174     function test_wp_filter_post_kses_abbr( $string, $expect_string ) {
     174    public function test_wp_filter_post_kses_abbr( $string, $expect_string ) {
    175175        global $allowedposttags;
    176176
     
    186186     * }
    187187     */
    188     function data_wp_filter_post_kses_abbr() {
     188    public function data_wp_filter_post_kses_abbr() {
    189189        $attributes = array(
    190190            'class' => 'classname',
     
    205205    }
    206206
    207     function test_feed_links() {
     207    public function test_feed_links() {
    208208        global $allowedposttags;
    209209
     
    239239    }
    240240
    241     function test_wp_kses_bad_protocol() {
     241    public function test_wp_kses_bad_protocol() {
    242242        $bad = array(
    243243            'dummy:alert(1)',
     
    475475    }
    476476
    477     function _wp_kses_allowed_html_filter( $html, $context ) {
     477    public function wp_kses_allowed_html_filter( $html, $context ) {
    478478        if ( 'post' === $context ) {
    479479            return array( 'a' => array( 'href' => true ) );
     
    524524        $this->assertSame( $custom_tags, wp_kses_allowed_html( $custom_tags ) );
    525525
    526         add_filter( 'wp_kses_allowed_html', array( $this, '_wp_kses_allowed_html_filter' ), 10, 2 );
     526        add_filter( 'wp_kses_allowed_html', array( $this, 'wp_kses_allowed_html_filter' ), 10, 2 );
    527527
    528528        $this->assertSame( array( 'a' => array( 'href' => true ) ), wp_kses_allowed_html( 'post' ) );
    529529        $this->assertSame( array( 'a' => array( 'href' => false ) ), wp_kses_allowed_html( 'data' ) );
    530530
    531         remove_filter( 'wp_kses_allowed_html', array( $this, '_wp_kses_allowed_html_filter' ) );
     531        remove_filter( 'wp_kses_allowed_html', array( $this, 'wp_kses_allowed_html_filter' ) );
    532532        $this->assertSame( $allowedposttags, wp_kses_allowed_html( 'post' ) );
    533533        $this->assertSame( $allowedtags, wp_kses_allowed_html( 'data' ) );
    534534    }
    535535
    536     function test_hyphenated_tag() {
     536    public function test_hyphenated_tag() {
    537537        $string                 = '<hyphenated-tag attribute="value" otherattribute="value2">Alot of hyphens.</hyphenated-tag>';
    538538        $custom_tags            = array(
     
    569569     * @dataProvider data_ctrl_removal
    570570     */
    571     function test_ctrl_removal( $input, $output ) {
     571    public function test_ctrl_removal( $input, $output ) {
    572572        global $allowedposttags;
    573573
     
    575575    }
    576576
    577     function data_ctrl_removal() {
     577    public function data_ctrl_removal() {
    578578        return array(
    579579            array(
     
    606606     * @dataProvider data_slash_zero_removal
    607607     */
    608     function test_slash_zero_removal( $input, $output ) {
     608    public function test_slash_zero_removal( $input, $output ) {
    609609        global $allowedposttags;
    610610
     
    612612    }
    613613
    614     function data_slash_zero_removal() {
     614    public function data_slash_zero_removal() {
    615615        return array(
    616616            array(
     
    658658     * @dataProvider data_hair_parse
    659659     */
    660     function test_hair_parse( $input, $output ) {
     660    public function test_hair_parse( $input, $output ) {
    661661        return $this->assertSame( $output, wp_kses_hair_parse( $input ) );
    662662    }
    663663
    664     function data_hair_parse() {
     664    public function data_hair_parse() {
    665665        return array(
    666666            array(
     
    724724     * @dataProvider data_attr_parse
    725725     */
    726     function test_attr_parse( $input, $output ) {
     726    public function test_attr_parse( $input, $output ) {
    727727        return $this->assertSame( $output, wp_kses_attr_parse( $input ) );
    728728    }
    729729
    730     function data_attr_parse() {
     730    public function data_attr_parse() {
    731731        return array(
    732732            array(
     
    782782     * @dataProvider data_one_attr
    783783     */
    784     function test_one_attr( $element, $input, $output ) {
     784    public function test_one_attr( $element, $input, $output ) {
    785785        return $this->assertSame( $output, wp_kses_one_attr( $input, $element ) );
    786786    }
    787787
    788     function data_one_attr() {
     788    public function data_one_attr() {
    789789        return array(
    790790            array(
     
    859859     * @ticket 34063
    860860     */
    861     function test_bdo() {
     861    public function test_bdo() {
    862862        global $allowedposttags;
    863863
     
    870870     * @ticket 35079
    871871     */
    872     function test_ol_reversed() {
     872    public function test_ol_reversed() {
    873873        global $allowedposttags;
    874874
     
    881881     * @ticket 40680
    882882     */
    883     function test_wp_kses_attr_no_attributes_allowed_with_empty_array() {
     883    public function test_wp_kses_attr_no_attributes_allowed_with_empty_array() {
    884884        $element   = 'foo';
    885885        $attribute = 'title="foo" class="bar"';
     
    891891     * @ticket 40680
    892892     */
    893     function test_wp_kses_attr_no_attributes_allowed_with_true() {
     893    public function test_wp_kses_attr_no_attributes_allowed_with_true() {
    894894        $element   = 'foo';
    895895        $attribute = 'title="foo" class="bar"';
     
    901901     * @ticket 40680
    902902     */
    903     function test_wp_kses_attr_single_attribute_is_allowed() {
     903    public function test_wp_kses_attr_single_attribute_is_allowed() {
    904904        $element   = 'foo';
    905905        $attribute = 'title="foo" class="bar"';
     
    911911     * @ticket 43312
    912912     */
    913     function test_wp_kses_attr_no_attributes_allowed_with_false() {
     913    public function test_wp_kses_attr_no_attributes_allowed_with_false() {
    914914        $element   = 'foo';
    915915        $attribute = 'title="foo" class="bar"';
     
    11171117     * @ticket 33121
    11181118     */
    1119     function test_wp_kses_attr_data_attribute_is_allowed() {
     1119    public function test_wp_kses_attr_data_attribute_is_allowed() {
    11201120        $test     = '<div data-foo="foo" data-bar="bar" datainvalid="gone" data--invaild="gone"  data-also-invaild-="gone" data-two-hyphens="remains">Pens and pencils</div>';
    11211121        $expected = '<div data-foo="foo" data-bar="bar" data-two-hyphens="remains">Pens and pencils</div>';
     
    11291129     * @ticket 33121
    11301130     */
    1131     function test_wildcard_requires_hyphen_after_prefix() {
     1131    public function test_wildcard_requires_hyphen_after_prefix() {
    11321132        $allowed_html = array(
    11331133            'div' => array(
     
    11501150     * @ticket 33121
    11511151     */
    1152     function test_wildcard_allows_two_hyphens() {
     1152    public function test_wildcard_allows_two_hyphens() {
    11531153        $allowed_html = array(
    11541154            'div' => array(
     
    11721172     * @ticket 33121
    11731173     */
    1174     function test_wildcard_attribute_prefixes( $wildcard_attribute, $expected ) {
     1174    public function test_wildcard_attribute_prefixes( $wildcard_attribute, $expected ) {
    11751175        $allowed_html = array(
    11761176            'div' => array(
     
    11931193     *               [1] The outcome of `wp_kses_attr_check` for the prefix.
    11941194     */
    1195     function data_wildcard_attribute_prefixes() {
     1195    public function data_wildcard_attribute_prefixes() {
    11961196        return array(
    11971197            // Ends correctly.
     
    12191219     * @param $expected string The sanitized style attribute.
    12201220     */
    1221     function test_kses_style_attr_with_url( $input, $expected ) {
     1221    public function test_kses_style_attr_with_url( $input, $expected ) {
    12221222        $actual = safecss_filter_attr( $input );
    12231223
     
    12301230     * @return array Nested array of input, expected pairs.
    12311231     */
    1232     function data_kses_style_attr_with_url() {
     1232    public function data_kses_style_attr_with_url() {
    12331233        return array(
    12341234            /*
     
    14631463     * @ticket 50731
    14641464     */
    1465     function test_wp_kses_img_tag_standard_attributes() {
     1465    public function test_wp_kses_img_tag_standard_attributes() {
    14661466        $html = array(
    14671467            '<img',
     
    14851485     * @ticket 53156
    14861486     */
    1487     function test_wp_kses_main_tag_standard_attributes() {
     1487    public function test_wp_kses_main_tag_standard_attributes() {
    14881488        $test = array(
    14891489            '<main',
Note: See TracChangeset for help on using the changeset viewer.