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/formatting/balanceTags.php

    r50000 r52010  
    66class Tests_Formatting_BalanceTags extends WP_UnitTestCase {
    77
    8     function nestable_tags() {
     8    public function nestable_tags() {
    99        return array(
    1010            array( 'blockquote' ),
     
    1717
    1818    // This is a complete(?) listing of valid single/self-closing tags.
    19     function single_tags() {
     19    public function single_tags() {
    2020        return array(
    2121            array( 'area' ),
     
    3838    }
    3939
    40     function supported_traditional_tag_names() {
     40    public function supported_traditional_tag_names() {
    4141        return array(
    4242            array( 'a' ),
     
    5050    }
    5151
    52     function supported_custom_element_tag_names() {
     52    public function supported_custom_element_tag_names() {
    5353        return array(
    5454            array( 'custom-element' ),
     
    6262    }
    6363
    64     function invalid_tag_names() {
     64    public function invalid_tag_names() {
    6565        return array(
    6666            array( '<0-day>inside', '&lt;0-day>inside' ), // Can't start with a number - handled by the "<3" fix.
     
    7474     * @see https://w3c.github.io/webcomponents/spec/custom/#valid-custom-element-name
    7575     */
    76     function unsupported_valid_tag_names() {
     76    public function unsupported_valid_tag_names() {
    7777        return array(
    7878            // We don't allow ending in a dash.
     
    134134     * @see https://w3c.github.io/webcomponents/spec/custom/#valid-custom-element-name
    135135     */
    136     function supported_invalid_tag_names() {
     136    public function supported_invalid_tag_names() {
    137137        return array(
    138138            // Reserved names for custom elements.
     
    152152     * @dataProvider supported_traditional_tag_names
    153153     */
    154     function test_detects_traditional_tag_names( $tag ) {
     154    public function test_detects_traditional_tag_names( $tag ) {
    155155        $normalized = strtolower( $tag );
    156156
     
    162162     * @dataProvider supported_custom_element_tag_names
    163163     */
    164     function test_detects_supported_custom_element_tag_names( $tag ) {
     164    public function test_detects_supported_custom_element_tag_names( $tag ) {
    165165        $this->assertSame( "<$tag>inside</$tag>", balanceTags( "<$tag>inside", true ) );
    166166    }
     
    170170     * @dataProvider invalid_tag_names
    171171     */
    172     function test_ignores_invalid_tag_names( $input, $output ) {
     172    public function test_ignores_invalid_tag_names( $input, $output ) {
    173173        $this->assertSame( $output, balanceTags( $input, true ) );
    174174    }
     
    178178     * @dataProvider unsupported_valid_tag_names
    179179     */
    180     function test_ignores_unsupported_custom_tag_names( $tag ) {
     180    public function test_ignores_unsupported_custom_tag_names( $tag ) {
    181181        $this->assertSame( "<$tag>inside", balanceTags( "<$tag>inside", true ) );
    182182    }
     
    186186     * @dataProvider supported_invalid_tag_names
    187187     */
    188     function test_detects_supported_invalid_tag_names( $tag ) {
     188    public function test_detects_supported_invalid_tag_names( $tag ) {
    189189        $this->assertSame( "<$tag>inside</$tag>", balanceTags( "<$tag>inside", true ) );
    190190    }
     
    196196     * @dataProvider single_tags
    197197     */
    198     function test_selfcloses_unclosed_known_single_tags( $tag ) {
     198    public function test_selfcloses_unclosed_known_single_tags( $tag ) {
    199199        $this->assertSame( "<$tag />", balanceTags( "<$tag>", true ) );
    200200    }
     
    207207     * @dataProvider single_tags
    208208     */
    209     function test_selfcloses_known_single_tags_having_closing_tag( $tag ) {
     209    public function test_selfcloses_known_single_tags_having_closing_tag( $tag ) {
    210210        $this->assertSame( "<$tag />", balanceTags( "<$tag></$tag>", true ) );
    211211    }
     
    214214     * @ticket 1597
    215215     */
    216     function test_closes_unknown_single_tags_with_closing_tag() {
     216    public function test_closes_unknown_single_tags_with_closing_tag() {
    217217
    218218        $inputs   = array(
     
    237237    }
    238238
    239     function test_closes_unclosed_single_tags_having_attributes() {
     239    public function test_closes_unclosed_single_tags_having_attributes() {
    240240        $inputs   = array(
    241241            '<img src="/images/example.png">',
     
    252252    }
    253253
    254     function test_allows_validly_closed_single_tags() {
     254    public function test_allows_validly_closed_single_tags() {
    255255        $inputs = array(
    256256            '<br />',
     
    268268     * @dataProvider nestable_tags
    269269     */
    270     function test_balances_nestable_tags( $tag ) {
     270    public function test_balances_nestable_tags( $tag ) {
    271271        $inputs   = array(
    272272            "<$tag>Test<$tag>Test</$tag>",
     
    285285    }
    286286
    287     function test_allows_adjacent_nestable_tags() {
     287    public function test_allows_adjacent_nestable_tags() {
    288288        $inputs = array(
    289289            '<blockquote><blockquote>Example quote</blockquote></blockquote>',
     
    302302     * @ticket 20401
    303303     */
    304     function test_allows_immediately_nested_object_tags() {
     304    public function test_allows_immediately_nested_object_tags() {
    305305        $object = '<object id="obj1"><param name="param1"/><object id="obj2"><param name="param2"/></object></object>';
    306306        $this->assertSame( $object, balanceTags( $object, true ) );
    307307    }
    308308
    309     function test_balances_nested_non_nestable_tags() {
     309    public function test_balances_nested_non_nestable_tags() {
    310310        $inputs   = array(
    311311            '<b><b>This is bold</b></b>',
     
    322322    }
    323323
    324     function test_fixes_improper_closing_tag_sequence() {
     324    public function test_fixes_improper_closing_tag_sequence() {
    325325        $inputs   = array(
    326326            '<p>Here is a <strong class="part">bold <em>and emphasis</p></em></strong>',
     
    337337    }
    338338
    339     function test_adds_missing_closing_tags() {
     339    public function test_adds_missing_closing_tags() {
    340340        $inputs   = array(
    341341            '<b><i>Test</b>',
     
    358358    }
    359359
    360     function test_removes_extraneous_closing_tags() {
     360    public function test_removes_extraneous_closing_tags() {
    361361        $inputs   = array(
    362362            '<b>Test</b></b>',
Note: See TracChangeset for help on using the changeset viewer.