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/xmlrpc/mw/newPost.php

    r51968 r52010  
    66class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase {
    77
    8     function test_invalid_username_password() {
     8    public function test_invalid_username_password() {
    99        $post   = array();
    1010        $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'username', 'password', $post ) );
     
    1313    }
    1414
    15     function test_incapable_user() {
     15    public function test_incapable_user() {
    1616        $this->make_user_by_role( 'subscriber' );
    1717
     
    2222    }
    2323
    24     function test_no_content() {
    25         if ( PHP_VERSION_ID >= 80100 ) {
    26             /*
    27              * For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
    28              * via hooked in filter functions until a more structural solution to the
    29              * "missing input validation" conundrum has been architected and implemented.
    30              */
    31             $this->expectDeprecation();
    32             $this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
    33         }
    34 
     24    public function test_no_content() {
    3525        $this->make_user_by_role( 'author' );
    3626
     
    4232    }
    4333
    44     function test_basic_content() {
    45         if ( PHP_VERSION_ID >= 80100 ) {
    46             /*
    47              * For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
    48              * via hooked in filter functions until a more structural solution to the
    49              * "missing input validation" conundrum has been architected and implemented.
    50              */
    51             $this->expectDeprecation();
    52             $this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
    53         }
    54 
     34    public function test_basic_content() {
    5535        $this->make_user_by_role( 'author' );
    5636
     
    6141    }
    6242
    63     function test_ignore_id() {
    64         if ( PHP_VERSION_ID >= 80100 ) {
    65             /*
    66              * For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
    67              * via hooked in filter functions until a more structural solution to the
    68              * "missing input validation" conundrum has been architected and implemented.
    69              */
    70             $this->expectDeprecation();
    71             $this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
    72         }
    73 
     43    public function test_ignore_id() {
    7444        $this->make_user_by_role( 'author' );
    7545
     
    8353    }
    8454
    85     function test_capable_publish() {
    86         if ( PHP_VERSION_ID >= 80100 ) {
    87             /*
    88              * For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
    89              * via hooked in filter functions until a more structural solution to the
    90              * "missing input validation" conundrum has been architected and implemented.
    91              */
    92             $this->expectDeprecation();
    93             $this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
    94         }
    95 
     55    public function test_capable_publish() {
    9656        $this->make_user_by_role( 'author' );
    9757
     
    10464    }
    10565
    106     function test_incapable_publish() {
     66    public function test_incapable_publish() {
    10767        $this->make_user_by_role( 'contributor' );
    10868
     
    11676    }
    11777
    118     function test_capable_other_author() {
    119         if ( PHP_VERSION_ID >= 80100 ) {
    120             /*
    121              * For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
    122              * via hooked in filter functions until a more structural solution to the
    123              * "missing input validation" conundrum has been architected and implemented.
    124              */
    125             $this->expectDeprecation();
    126             $this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
    127         }
    128 
     78    public function test_capable_other_author() {
    12979        $this->make_user_by_role( 'editor' );
    13080        $other_author_id = $this->make_user_by_role( 'author' );
     
    13888    }
    13989
    140     function test_incapable_other_author() {
     90    public function test_incapable_other_author() {
    14191        $this->make_user_by_role( 'contributor' );
    14292        $other_author_id = $this->make_user_by_role( 'author' );
     
    154104     * @ticket 20356
    155105     */
    156     function test_invalid_author() {
     106    public function test_invalid_author() {
    157107        $this->make_user_by_role( 'editor' );
    158108
     
    166116    }
    167117
    168     function test_empty_author() {
    169         if ( PHP_VERSION_ID >= 80100 ) {
    170             /*
    171              * For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
    172              * via hooked in filter functions until a more structural solution to the
    173              * "missing input validation" conundrum has been architected and implemented.
    174              */
    175             $this->expectDeprecation();
    176             $this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
    177         }
    178 
     118    public function test_empty_author() {
    179119        $my_author_id = $this->make_user_by_role( 'author' );
    180120
     
    192132     * @requires function imagejpeg
    193133     */
    194     function test_post_thumbnail() {
     134    public function test_post_thumbnail() {
    195135        add_theme_support( 'post-thumbnails' );
    196136
     
    212152    }
    213153
    214     function test_incapable_set_post_type_as_page() {
     154    public function test_incapable_set_post_type_as_page() {
    215155        $this->make_user_by_role( 'author' );
    216156
     
    224164    }
    225165
    226     function test_capable_set_post_type_as_page() {
    227         if ( PHP_VERSION_ID >= 80100 ) {
    228             /*
    229              * For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
    230              * via hooked in filter functions until a more structural solution to the
    231              * "missing input validation" conundrum has been architected and implemented.
    232              */
    233             $this->expectDeprecation();
    234             $this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
    235         }
    236 
     166    public function test_capable_set_post_type_as_page() {
    237167        $this->make_user_by_role( 'editor' );
    238168
     
    254184     * @ticket 16985
    255185     */
    256     function test_draft_post_date() {
    257         if ( PHP_VERSION_ID >= 80100 ) {
    258             /*
    259              * For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
    260              * via hooked in filter functions until a more structural solution to the
    261              * "missing input validation" conundrum has been architected and implemented.
    262              */
    263             $this->expectDeprecation();
    264             $this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
    265         }
    266 
     186    public function test_draft_post_date() {
    267187        $this->make_user_by_role( 'editor' );
    268188
Note: See TracChangeset for help on using the changeset viewer.