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/db.php

    r51568 r52010  
    122122         * @ticket 10041
    123123         */
    124         function test_esc_like() {
     124        public function test_esc_like() {
    125125                global $wpdb;
    126126
    … …  
    158158         * @param $result string The expected comparison result; '1' = true, '0' = false
    159159         */
    160         function test_like_query( $data, $like, $result ) {
     160        public function test_like_query( $data, $like, $result ) {
    161161                global $wpdb;
    162162                return $this->assertSame( $result, $wpdb->get_var( $wpdb->prepare( 'SELECT %s LIKE %s', $data, $wpdb->esc_like( $like ) ) ) );
    163163        }
    164164
    165         function data_like_query() {
     165        public function data_like_query() {
    166166                return array(
    167167                        array(
    … …  
    221221         * @ticket 18510
    222222         */
    223         function test_wpdb_supposedly_protected_properties() {
     223        public function test_wpdb_supposedly_protected_properties() {
    224224                global $wpdb;
    225225
    … …  
    237237         * @ticket 21212
    238238         */
    239         function test_wpdb_actually_protected_properties() {
     239        public function test_wpdb_actually_protected_properties() {
    240240                global $wpdb;
    241241
    … …  
    252252         * @ticket 18510
    253253         */
    254         function test_wpdb_nonexistent_properties() {
     254        public function test_wpdb_nonexistent_properties() {
    255255                global $wpdb;
    256256
    … …  
    283283         * @ticket 26847
    284284         */
    285         function test_set_sql_mode() {
     285        public function test_set_sql_mode() {
    286286                global $wpdb;
    287287
    … …  
    303303         * @ticket 26847
    304304         */
    305         function test_set_incompatible_sql_mode() {
     305        public function test_set_incompatible_sql_mode() {
    306306                global $wpdb;
    307307
    … …  
    321321         * @ticket 26847
    322322         */
    323         function test_set_allowed_incompatible_sql_mode() {
     323        public function test_set_allowed_incompatible_sql_mode() {
    324324                global $wpdb;
    325325
    … …  
    354354         * @expectedIncorrectUsage wpdb::prepare
    355355         */
    356         function test_prepare_without_arguments() {
     356        public function test_prepare_without_arguments() {
    357357                global $wpdb;
    358358                $id = 0;
    … …  
    363363        }
    364364
    365         function test_prepare_sprintf() {
     365        public function test_prepare_sprintf() {
    366366                global $wpdb;
    367367
    … …  
    373373         * @expectedIncorrectUsage wpdb::prepare
    374374         */
    375         function test_prepare_sprintf_invalid_args() {
     375        public function test_prepare_sprintf_invalid_args() {
    376376                global $wpdb;
    377377
    … …  
    385385        }
    386386
    387         function test_prepare_vsprintf() {
     387        public function test_prepare_vsprintf() {
    388388                global $wpdb;
    389389
    … …  
    395395         * @expectedIncorrectUsage wpdb::prepare
    396396         */
    397         function test_prepare_vsprintf_invalid_args() {
     397        public function test_prepare_vsprintf_invalid_args() {
    398398                global $wpdb;
    399399
    … …  
    472472        }
    473473
    474         function test_db_version() {
     474        public function test_db_version() {
    475475                global $wpdb;
    476476
    … …  
    478478        }
    479479
    480         function test_get_caller() {
     480        public function test_get_caller() {
    481481                global $wpdb;
    482482                $str    = $wpdb->get_caller();
    … …  
    486486        }
    487487
    488         function test_has_cap() {
     488        public function test_has_cap() {
    489489                global $wpdb;
    490490                $this->assertTrue( $wpdb->has_cap( 'collation' ) );
    … …  
    507507         * @expectedDeprecated supports_collation
    508508         */
    509         function test_supports_collation() {
     509        public function test_supports_collation() {
    510510                global $wpdb;
    511511                $this->assertTrue( $wpdb->supports_collation() );
    512512        }
    513513
    514         function test_check_database_version() {
     514        public function test_check_database_version() {
    515515                global $wpdb;
    516516                $this->assertEmpty( $wpdb->check_database_version() );
    517517        }
    518518
    519         function test_bail() {
     519        public function test_bail() {
    520520                global $wpdb;
    521521
    … …  
    524524        }
    525525
    526         function test_timers() {
     526        public function test_timers() {
    527527                global $wpdb;
    528528
    … …  
    535535        }
    536536
    537         function test_get_col_info() {
     537        public function test_get_col_info() {
    538538                global $wpdb;
    539539
    … …  
    545545        }
    546546
    547         function test_query_and_delete() {
     547        public function test_query_and_delete() {
    548548                global $wpdb;
    549549                $rows = $wpdb->query( "INSERT INTO $wpdb->users (display_name) VALUES ('Walter Sobchak')" );
    … …  
    554554        }
    555555
    556         function test_get_row() {
     556        public function test_get_row() {
    557557                global $wpdb;
    558558                $rows = $wpdb->query( "INSERT INTO $wpdb->users (display_name) VALUES ('Walter Sobchak')" );
    … …  
    577577         * @ticket 45299
    578578         */
    579         function test_get_col( $query, $expected, $last_result, $column ) {
     579        public function test_get_col( $query, $expected, $last_result, $column ) {
    580580                global $wpdb;
    581581
    … …  
    607607         *     @type int|string         $column      The column index to retrieve.
    608608         */
    609         function data_test_get_col() {
     609        public function data_test_get_col() {
    610610                global $wpdb;
    611611
    … …  
    656656        }
    657657
    658         function test_replace() {
     658        public function test_replace() {
    659659                global $wpdb;
    660660                $rows1 = $wpdb->insert( $wpdb->users, array( 'display_name' => 'Walter Sobchak' ) );
    … …  
    684684         * @ticket 26106
    685685         */
    686         function test_empty_where_on_update() {
     686        public function test_empty_where_on_update() {
    687687                global $wpdb;
    688688                $suppress = $wpdb->suppress_errors( true );
    … …  
    706706         * @ticket 28155
    707707         */
    708         function test_mysqli_flush_sync() {
     708        public function test_mysqli_flush_sync() {
    709709                global $wpdb;
    710710                if ( ! $wpdb->use_mysqli ) {
    … …  
    742742         * @ticket 32763
    743743         */
    744         function data_get_table_from_query() {
     744        public function data_get_table_from_query() {
    745745                $table       = 'a_test_table_name';
    746746                $more_tables = array(
    … …  
    866866         * @ticket 21212
    867867         */
    868         function test_get_table_from_query( $query, $table ) {
     868        public function test_get_table_from_query( $query, $table ) {
    869869                $this->assertSame( $table, self::$_wpdb->get_table_from_query( $query ) );
    870870        }
    871871
    872         function data_get_table_from_query_false() {
     872        public function data_get_table_from_query_false() {
    873873                $table = 'a_test_table_name';
    874874                return array(
    … …  
    881881         * @ticket 21212
    882882         */
    883         function test_get_table_from_query_false( $query ) {
     883        public function test_get_table_from_query_false( $query ) {
    884884                $this->assertFalse( self::$_wpdb->get_table_from_query( $query ) );
    885885        }
    … …  
    888888         * @ticket 38751
    889889         */
    890         function data_get_escaped_table_from_show_query() {
     890        public function data_get_escaped_table_from_show_query() {
    891891                return array(
    892892                        // Equality.
    … …  
    908908         * @ticket 38751
    909909         */
    910         function test_get_escaped_table_from_show_query( $query, $table ) {
     910        public function test_get_escaped_table_from_show_query( $query, $table ) {
    911911                $this->assertSame( $table, self::$_wpdb->get_table_from_query( $query ) );
    912912        }
    … …  
    915915         * @ticket 21212
    916916         */
    917         function data_process_field_formats() {
     917        public function data_process_field_formats() {
    918918                $core_db_fields_no_format_specified = array(
    919919                        array(
    … …  
    10231023         * @ticket 21212
    10241024         */
    1025         function test_process_field_formats( $data, $format, $expected, $message ) {
     1025        public function test_process_field_formats( $data, $format, $expected, $message ) {
    10261026                $actual = self::$_wpdb->process_field_formats( $data, $format );
    10271027                $this->assertSame( $expected, $actual, $message );
    … …  
    10311031         * @ticket 21212
    10321032         */
    1033         function test_process_fields() {
     1033        public function test_process_fields() {
    10341034                global $wpdb;
    10351035
    … …  
    10611061         * @depends test_process_fields
    10621062         */
    1063         function test_process_fields_on_nonexistent_table( $data ) {
     1063        public function test_process_fields_on_nonexistent_table( $data ) {
    10641064                self::$_wpdb->suppress_errors( true );
    10651065                $data = array( 'post_content' => '¡foo foo foo!' );
    … …  
    10711071         * @ticket 21212
    10721072         */
    1073         function test_pre_get_table_charset_filter() {
     1073        public function test_pre_get_table_charset_filter() {
    10741074                add_filter( 'pre_get_table_charset', array( $this, 'filter_pre_get_table_charset' ), 10, 2 );
    10751075                $charset = self::$_wpdb->get_table_charset( 'some_table' );
    … …  
    10781078                $this->assertSame( $charset, 'fake_charset' );
    10791079        }
    1080         function filter_pre_get_table_charset( $charset, $table ) {
     1080        public function filter_pre_get_table_charset( $charset, $table ) {
    10811081                return 'fake_charset';
    10821082        }
    … …  
    10851085         * @ticket 21212
    10861086         */
    1087         function test_pre_get_col_charset_filter() {
     1087        public function test_pre_get_col_charset_filter() {
    10881088                add_filter( 'pre_get_col_charset', array( $this, 'filter_pre_get_col_charset' ), 10, 3 );
    10891089                $charset = self::$_wpdb->get_col_charset( 'some_table', 'some_col' );
    … …  
    10921092                $this->assertSame( $charset, 'fake_col_charset' );
    10931093        }
    1094         function filter_pre_get_col_charset( $charset, $table, $column ) {
     1094        public function filter_pre_get_col_charset( $charset, $table, $column ) {
    10951095                return 'fake_col_charset';
    10961096        }
    … …  
    10991099         * @ticket 15158
    11001100         */
    1101         function test_null_insert() {
     1101        public function test_null_insert() {
    11021102                global $wpdb;
    11031103
    … …  
    11211121         * @ticket 15158
    11221122         */
    1123         function test_null_update_value() {
     1123        public function test_null_update_value() {
    11241124                global $wpdb;
    11251125
    … …  
    11591159         * @ticket 15158
    11601160         */
    1161         function test_null_update_where() {
     1161        public function test_null_update_where() {
    11621162                global $wpdb;
    11631163
    … …  
    11971197         * @ticket 15158
    11981198         */
    1199         function test_null_delete() {
     1199        public function test_null_delete() {
    12001200                global $wpdb;
    12011201
    … …  
    12331233         * @ticket 34903
    12341234         */
    1235         function test_close() {
     1235        public function test_close() {
    12361236                global $wpdb;
    12371237
    … …  
    12521252         * @ticket 36917
    12531253         */
    1254         function test_charset_not_determined_when_disconnected() {
     1254        public function test_charset_not_determined_when_disconnected() {
    12551255                global $wpdb;
    12561256
    … …  
    12701270         * @ticket 36917
    12711271         */
    1272         function test_charset_switched_to_utf8mb4() {
     1272        public function test_charset_switched_to_utf8mb4() {
    12731273                global $wpdb;
    12741274
    … …  
    12891289         * @ticket 36917
    12901290         */
    1291         function test_collate_switched_to_utf8mb4_520() {
     1291        public function test_collate_switched_to_utf8mb4_520() {
    12921292                global $wpdb;
    12931293
    … …  
    13081308         * @ticket 36917
    13091309         */
    1310         function test_non_unicode_collations() {
     1310        public function test_non_unicode_collations() {
    13111311                global $wpdb;
    13121312
    … …  
    13261326         * @ticket 37982
    13271327         */
    1328         function test_charset_switched_to_utf8() {
     1328        public function test_charset_switched_to_utf8() {
    13291329                global $wpdb;
    13301330
    … …  
    13451345         * @dataProvider data_prepare_with_placeholders
    13461346         */
    1347         function test_prepare_with_placeholders_and_individual_args( $sql, $values, $incorrect_usage, $expected ) {
     1347        public function test_prepare_with_placeholders_and_individual_args( $sql, $values, $incorrect_usage, $expected ) {
    13481348                global $wpdb;
    13491349
    … …  
    13641364         * @dataProvider data_prepare_with_placeholders
    13651365         */
    1366         function test_prepare_with_placeholders_and_array_args( $sql, $values, $incorrect_usage, $expected ) {
     1366        public function test_prepare_with_placeholders_and_array_args( $sql, $values, $incorrect_usage, $expected ) {
    13671367                global $wpdb;
    13681368
    … …  
    13801380        }
    13811381
    1382         function data_prepare_with_placeholders() {
     1382        public function data_prepare_with_placeholders() {
    13831383                global $wpdb;
    13841384
    … …  
    15581558         * @dataProvider data_escape_and_prepare
    15591559         */
    1560         function test_escape_and_prepare( $escape, $sql, $values, $incorrect_usage, $expected ) {
     1560        public function test_escape_and_prepare( $escape, $sql, $values, $incorrect_usage, $expected ) {
    15611561                global $wpdb;
    15621562
    … …  
    15751575        }
    15761576
    1577         function data_escape_and_prepare() {
     1577        public function data_escape_and_prepare() {
    15781578                global $wpdb;
    15791579                return array(
    … …  
    16051605         * @expectedIncorrectUsage wpdb::prepare
    16061606         */
    1607         function test_double_prepare() {
     1607        public function test_double_prepare() {
    16081608                global $wpdb;
    16091609
    … …  
    16151615        }
    16161616
    1617         function test_prepare_numeric_placeholders_float_args() {
     1617        public function test_prepare_numeric_placeholders_float_args() {
    16181618                global $wpdb;
    16191619
    … …  
    16301630        }
    16311631
    1632         function test_prepare_numeric_placeholders_float_array() {
     1632        public function test_prepare_numeric_placeholders_float_array() {
    16331633                global $wpdb;
    16341634
    … …  
    16441644        }
    16451645
    1646         function test_query_unescapes_placeholders() {
     1646        public function test_query_unescapes_placeholders() {
    16471647                global $wpdb;
    16481648
    … …  
    16631663        }
    16641664
    1665         function test_esc_sql_with_unsupported_placeholder_type() {
     1665        public function test_esc_sql_with_unsupported_placeholder_type() {
    16661666                global $wpdb;
    16671667
Note: See TracChangeset for help on using the changeset viewer.