Make WordPress Core


Ignore:
Timestamp:
11/04/2021 03:22:47 PM (5 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/wp/newPost.php

    r51968 r52010  
    66class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase {
    77
    8         function test_invalid_username_password() {
     8        public function test_invalid_username_password() {
    99                $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'username', 'password', array() ) );
    1010                $this->assertIXRError( $result );
     
    1212        }
    1313
    14         function test_incapable_user() {
     14        public function test_incapable_user() {
    1515                $this->make_user_by_role( 'subscriber' );
    1616
     
    2020        }
    2121
    22         function test_no_content() {
    23                 if ( PHP_VERSION_ID >= 80100 ) {
    24                         /*
    25                          * For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
    26                          * via hooked in filter functions until a more structural solution to the
    27                          * "missing input validation" conundrum has been architected and implemented.
    28                          */
    29                         $this->expectDeprecation();
    30                         $this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
    31                 }
    32 
     22        public function test_no_content() {
    3323                $this->make_user_by_role( 'author' );
    3424
     
    3929        }
    4030
    41         function test_basic_content() {
    42                 if ( PHP_VERSION_ID >= 80100 ) {
    43                         /*
    44                          * For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
    45                          * via hooked in filter functions until a more structural solution to the
    46                          * "missing input validation" conundrum has been architected and implemented.
    47                          */
    48                         $this->expectDeprecation();
    49                         $this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
    50                 }
    51 
     31        public function test_basic_content() {
    5232                $this->make_user_by_role( 'author' );
    5333
     
    5838        }
    5939
    60         function test_ignore_id() {
    61                 if ( PHP_VERSION_ID >= 80100 ) {
    62                         /*
    63                          * For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
    64                          * via hooked in filter functions until a more structural solution to the
    65                          * "missing input validation" conundrum has been architected and implemented.
    66                          */
    67                         $this->expectDeprecation();
    68                         $this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
    69                 }
    70 
     40        public function test_ignore_id() {
    7141                $this->make_user_by_role( 'author' );
    7242
     
    8050        }
    8151
    82         function test_capable_publish() {
    83                 if ( PHP_VERSION_ID >= 80100 ) {
    84                         /*
    85                          * For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
    86                          * via hooked in filter functions until a more structural solution to the
    87                          * "missing input validation" conundrum has been architected and implemented.
    88                          */
    89                         $this->expectDeprecation();
    90                         $this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
    91                 }
    92 
     52        public function test_capable_publish() {
    9353                $this->make_user_by_role( 'author' );
    9454
     
    10161        }
    10262
    103         function test_incapable_publish() {
     63        public function test_incapable_publish() {
    10464                $this->make_user_by_role( 'contributor' );
    10565
     
    11373        }
    11474
    115         function test_capable_private() {
    116                 if ( PHP_VERSION_ID >= 80100 ) {
    117                         /*
    118                          * For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
    119                          * via hooked in filter functions until a more structural solution to the
    120                          * "missing input validation" conundrum has been architected and implemented.
    121                          */
    122                         $this->expectDeprecation();
    123                         $this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
    124                 }
    125 
     75        public function test_capable_private() {
    12676                $this->make_user_by_role( 'editor' );
    12777
     
    13484        }
    13585
    136         function test_incapable_private() {
     86        public function test_incapable_private() {
    13787                $this->make_user_by_role( 'contributor' );
    13888
     
    14696        }
    14797
    148         function test_capable_other_author() {
    149                 if ( PHP_VERSION_ID >= 80100 ) {
    150                         /*
    151                          * For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
    152                          * via hooked in filter functions until a more structural solution to the
    153                          * "missing input validation" conundrum has been architected and implemented.
    154                          */
    155                         $this->expectDeprecation();
    156                         $this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
    157                 }
    158 
     98        public function test_capable_other_author() {
    15999                $other_author_id = $this->make_user_by_role( 'author' );
    160100                $this->make_user_by_role( 'editor' );
     
    168108        }
    169109
    170         function test_incapable_other_author() {
     110        public function test_incapable_other_author() {
    171111                $other_author_id = $this->make_user_by_role( 'author' );
    172112                $this->make_user_by_role( 'contributor' );
     
    181121        }
    182122
    183         function test_invalid_author() {
     123        public function test_invalid_author() {
    184124                $this->make_user_by_role( 'editor' );
    185125
     
    193133        }
    194134
    195         function test_empty_author() {
    196                 if ( PHP_VERSION_ID >= 80100 ) {
    197                         /*
    198                          * For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
    199                          * via hooked in filter functions until a more structural solution to the
    200                          * "missing input validation" conundrum has been architected and implemented.
    201                          */
    202                         $this->expectDeprecation();
    203                         $this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
    204                 }
    205 
     135        public function test_empty_author() {
    206136                $my_author_id = $this->make_user_by_role( 'author' );
    207137
     
    219149         * @requires function imagejpeg
    220150         */
    221         function test_post_thumbnail() {
     151        public function test_post_thumbnail() {
    222152                add_theme_support( 'post-thumbnails' );
    223153
     
    239169        }
    240170
    241         function test_invalid_post_status() {
    242                 if ( PHP_VERSION_ID >= 80100 ) {
    243                         /*
    244                          * For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
    245                          * via hooked in filter functions until a more structural solution to the
    246                          * "missing input validation" conundrum has been architected and implemented.
    247                          */
    248                         $this->expectDeprecation();
    249                         $this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
    250                 }
    251 
     171        public function test_invalid_post_status() {
    252172                $this->make_user_by_role( 'author' );
    253173
     
    261181        }
    262182
    263         function test_incapable_sticky() {
     183        public function test_incapable_sticky() {
    264184                $this->make_user_by_role( 'contributor' );
    265185
     
    273193        }
    274194
    275         function test_capable_sticky() {
    276                 if ( PHP_VERSION_ID >= 80100 ) {
    277                         /*
    278                          * For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
    279                          * via hooked in filter functions until a more structural solution to the
    280                          * "missing input validation" conundrum has been architected and implemented.
    281                          */
    282                         $this->expectDeprecation();
    283                         $this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
    284                 }
    285 
     195        public function test_capable_sticky() {
    286196                $this->make_user_by_role( 'editor' );
    287197
     
    295205        }
    296206
    297         function test_private_sticky() {
     207        public function test_private_sticky() {
    298208                $this->make_user_by_role( 'editor' );
    299209
     
    308218        }
    309219
    310         function test_post_format() {
    311                 if ( PHP_VERSION_ID >= 80100 ) {
    312                         /*
    313                          * For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
    314                          * via hooked in filter functions until a more structural solution to the
    315                          * "missing input validation" conundrum has been architected and implemented.
    316                          */
    317                         $this->expectDeprecation();
    318                         $this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
    319                 }
    320 
     220        public function test_post_format() {
    321221                $this->make_user_by_role( 'editor' );
    322222
     
    330230        }
    331231
    332         function test_invalid_post_format() {
    333                 if ( PHP_VERSION_ID >= 80100 ) {
    334                         /*
    335                          * For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
    336                          * via hooked in filter functions until a more structural solution to the
    337                          * "missing input validation" conundrum has been architected and implemented.
    338                          */
    339                         $this->expectDeprecation();
    340                         $this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
    341                 }
    342 
     232        public function test_invalid_post_format() {
    343233                $this->make_user_by_role( 'editor' );
    344234
     
    352242        }
    353243
    354         function test_invalid_taxonomy() {
     244        public function test_invalid_taxonomy() {
    355245                $this->make_user_by_role( 'editor' );
    356246
     
    376266        }
    377267
    378         function test_invalid_term_id() {
     268        public function test_invalid_term_id() {
    379269                $this->make_user_by_role( 'editor' );
    380270
     
    390280        }
    391281
    392         function test_terms() {
    393                 if ( PHP_VERSION_ID >= 80100 ) {
    394                         /*
    395                          * For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
    396                          * via hooked in filter functions until a more structural solution to the
    397                          * "missing input validation" conundrum has been architected and implemented.
    398                          */
    399                         $this->expectDeprecation();
    400                         $this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
    401                 }
    402 
     282        public function test_terms() {
    403283                $this->make_user_by_role( 'editor' );
    404284
     
    425305        }
    426306
    427         function test_terms_names() {
    428                 if ( PHP_VERSION_ID >= 80100 ) {
    429                         /*
    430                          * For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
    431                          * via hooked in filter functions until a more structural solution to the
    432                          * "missing input validation" conundrum has been architected and implemented.
    433                          */
    434                         $this->expectDeprecation();
    435                         $this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
    436                 }
    437 
     307        public function test_terms_names() {
    438308                $this->make_user_by_role( 'editor' );
    439309
     
    478348         * @ticket 28601
    479349         */
    480         function test_invalid_post_date_does_not_fatal() {
    481                 if ( PHP_VERSION_ID >= 80100 ) {
    482                         /*
    483                          * For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
    484                          * via hooked in filter functions until a more structural solution to the
    485                          * "missing input validation" conundrum has been architected and implemented.
    486                          */
    487                         $this->expectDeprecation();
    488                         $this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
    489                 }
    490 
     350        public function test_invalid_post_date_does_not_fatal() {
    491351                $this->make_user_by_role( 'author' );
    492352                $date_string  = 'invalid_date';
     
    505365         * @ticket 28601
    506366         */
    507         function test_invalid_post_date_gmt_does_not_fatal() {
    508                 if ( PHP_VERSION_ID >= 80100 ) {
    509                         /*
    510                          * For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
    511                          * via hooked in filter functions until a more structural solution to the
    512                          * "missing input validation" conundrum has been architected and implemented.
    513                          */
    514                         $this->expectDeprecation();
    515                         $this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
    516                 }
    517 
     367        public function test_invalid_post_date_gmt_does_not_fatal() {
    518368                $this->make_user_by_role( 'author' );
    519369                $date_string  = 'invalid_date';
     
    532382         * @ticket 28601
    533383         */
    534         function test_valid_string_post_date() {
    535                 if ( PHP_VERSION_ID >= 80100 ) {
    536                         /*
    537                          * For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
    538                          * via hooked in filter functions until a more structural solution to the
    539                          * "missing input validation" conundrum has been architected and implemented.
    540                          */
    541                         $this->expectDeprecation();
    542                         $this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
    543                 }
    544 
     384        public function test_valid_string_post_date() {
    545385                $this->make_user_by_role( 'author' );
    546386                $date_string  = '1984-01-11 05:00:00';
     
    559399         * @ticket 28601
    560400         */
    561         function test_valid_string_post_date_gmt() {
    562                 if ( PHP_VERSION_ID >= 80100 ) {
    563                         /*
    564                          * For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
    565                          * via hooked in filter functions until a more structural solution to the
    566                          * "missing input validation" conundrum has been architected and implemented.
    567                          */
    568                         $this->expectDeprecation();
    569                         $this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
    570                 }
    571 
     401        public function test_valid_string_post_date_gmt() {
    572402                $this->make_user_by_role( 'author' );
    573403                $date_string  = '1984-01-11 05:00:00';
     
    586416         * @ticket 28601
    587417         */
    588         function test_valid_IXR_post_date() {
    589                 if ( PHP_VERSION_ID >= 80100 ) {
    590                         /*
    591                          * For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
    592                          * via hooked in filter functions until a more structural solution to the
    593                          * "missing input validation" conundrum has been architected and implemented.
    594                          */
    595                         $this->expectDeprecation();
    596                         $this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
    597                 }
    598 
     418        public function test_valid_IXR_post_date() {
    599419                $this->make_user_by_role( 'author' );
    600420                $date_string  = '1984-01-11 05:00:00';
     
    613433         * @ticket 28601
    614434         */
    615         function test_valid_IXR_post_date_gmt() {
    616                 if ( PHP_VERSION_ID >= 80100 ) {
    617                         /*
    618                          * For the time being, ignoring PHP 8.1 "null to non-nullable" deprecations coming in
    619                          * via hooked in filter functions until a more structural solution to the
    620                          * "missing input validation" conundrum has been architected and implemented.
    621                          */
    622                         $this->expectDeprecation();
    623                         $this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
    624                 }
    625 
     435        public function test_valid_IXR_post_date_gmt() {
    626436                $this->make_user_by_role( 'author' );
    627437                $date_string  = '1984-01-11 05:00:00';
Note: See TracChangeset for help on using the changeset viewer.