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

    r51568 r52010  
    3636     * @ticket 21212
    3737     */
    38     function data_strip_invalid_text() {
     38    public function data_strip_invalid_text() {
    3939        $fields = array(
    4040            'latin1'                                => array(
     
    480480     * @covers wpdb::strip_invalid_text
    481481     */
    482     function test_strip_invalid_text( $data, $expected, $message ) {
     482    public function test_strip_invalid_text( $data, $expected, $message ) {
    483483        $charset = self::$_wpdb->charset;
    484484        if ( isset( $data[0]['connection_charset'] ) ) {
     
    513513     * @covers wpdb::process_fields
    514514     */
    515     function test_process_fields_failure() {
     515    public function test_process_fields_failure() {
    516516        global $wpdb;
    517517
     
    529529     * @ticket 21212
    530530     */
    531     function data_process_field_charsets() {
     531    public function data_process_field_charsets() {
    532532        if ( $GLOBALS['wpdb']->charset ) {
    533533            $charset = $GLOBALS['wpdb']->charset;
     
    600600     * @covers wpdb::process_field_charsets
    601601     */
    602     function test_process_field_charsets( $data, $expected, $message ) {
     602    public function test_process_field_charsets( $data, $expected, $message ) {
    603603        $actual = self::$_wpdb->process_field_charsets( $data, $GLOBALS['wpdb']->posts );
    604604        $this->assertSame( $expected, $actual, $message );
     
    612612     * @depends test_process_field_charsets
    613613     */
    614     function test_process_field_charsets_on_nonexistent_table() {
     614    public function test_process_field_charsets_on_nonexistent_table() {
    615615        $data = array(
    616616            'post_content' => array(
     
    629629     * @covers wpdb::check_ascii
    630630     */
    631     function test_check_ascii() {
     631    public function test_check_ascii() {
    632632        $ascii = "\0\t\n\r '" . '!"#$%&()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~';
    633633        $this->assertTrue( self::$_wpdb->check_ascii( $ascii ) );
     
    639639     * @covers wpdb::check_ascii
    640640     */
    641     function test_check_ascii_false() {
     641    public function test_check_ascii_false() {
    642642        $this->assertFalse( self::$_wpdb->check_ascii( 'ABCDEFGHIJKLMNOPQRSTUVWXYZ¡©«' ) );
    643643    }
     
    648648     * @covers wpdb::strip_invalid_text_for_column
    649649     */
    650     function test_strip_invalid_text_for_column() {
     650    public function test_strip_invalid_text_for_column() {
    651651        global $wpdb;
    652652
     
    738738     * @ticket 21212
    739739     */
    740     function data_test_get_table_charset() {
     740    public function data_test_get_table_charset() {
    741741        $table_name = 'test_get_table_charset';
    742742
     
    758758     * @covers wpdb::get_table_charset
    759759     */
    760     function test_get_table_charset( $drop, $create, $table, $expected_charset ) {
     760    public function test_get_table_charset( $drop, $create, $table, $expected_charset ) {
    761761        self::$_wpdb->query( $drop );
    762762
     
    779779     * @ticket 21212
    780780     */
    781     function data_test_get_column_charset() {
     781    public function data_test_get_column_charset() {
    782782        $table_name = 'test_get_column_charset';
    783783
     
    799799     * @covers wpdb::get_col_charset
    800800     */
    801     function test_get_column_charset( $drop, $create, $table, $expected_charset ) {
     801    public function test_get_column_charset( $drop, $create, $table, $expected_charset ) {
    802802        self::$_wpdb->query( $drop );
    803803
     
    822822     * @covers wpdb::get_col_charset
    823823     */
    824     function test_get_column_charset_non_mysql( $drop, $create, $table, $columns ) {
     824    public function test_get_column_charset_non_mysql( $drop, $create, $table, $columns ) {
    825825        self::$_wpdb->query( $drop );
    826826
     
    849849     * @covers wpdb::get_col_charset
    850850     */
    851     function test_get_column_charset_is_mysql_undefined( $drop, $create, $table, $columns ) {
     851    public function test_get_column_charset_is_mysql_undefined( $drop, $create, $table, $columns ) {
    852852        self::$_wpdb->query( $drop );
    853853
     
    873873     * @ticket 21212
    874874     */
    875     function data_strip_invalid_text_from_query() {
     875    public function data_strip_invalid_text_from_query() {
    876876        $table_name = 'strip_invalid_text_from_query_table';
    877877        $data       = array(
     
    909909     * @covers wpdb::strip_invalid_text_from_query
    910910     */
    911     function test_strip_invalid_text_from_query( $create, $query, $expected, $drop ) {
     911    public function test_strip_invalid_text_from_query( $create, $query, $expected, $drop ) {
    912912        self::$_wpdb->query( $drop );
    913913
     
    927927     * @ticket 32104
    928928     */
    929     function data_dont_strip_text_from_schema_queries() {
     929    public function data_dont_strip_text_from_schema_queries() {
    930930        // An obviously invalid and fake table name.
    931931        $table_name = "\xff\xff\xff\xff";
     
    953953     * @covers wpdb::strip_invalid_text_from_query
    954954     */
    955     function test_dont_strip_text_from_schema_queries( $query ) {
     955    public function test_dont_strip_text_from_schema_queries( $query ) {
    956956        $return = self::$_wpdb->strip_invalid_text_from_query( $query );
    957957        $this->assertSame( $query, $return );
     
    963963     * @covers wpdb::query
    964964     */
    965     function test_invalid_characters_in_query() {
     965    public function test_invalid_characters_in_query() {
    966966        global $wpdb;
    967967
     
    977977     * @ticket 21212
    978978     */
    979     function data_table_collation_check() {
     979    public function data_table_collation_check() {
    980980        $table_name = 'table_collation_check';
    981981        $data       = array(
     
    10351035     * @covers wpdb::check_safe_collation
    10361036     */
    1037     function test_table_collation_check( $create, $expected, $query, $drop, $always_true ) {
     1037    public function test_table_collation_check( $create, $expected, $query, $drop, $always_true ) {
    10381038        self::$_wpdb->query( $drop );
    10391039
     
    10541054     * @covers wpdb::strip_invalid_text_for_column
    10551055     */
    1056     function test_strip_invalid_text_for_column_bails_if_ascii_input_too_long() {
     1056    public function test_strip_invalid_text_for_column_bails_if_ascii_input_too_long() {
    10571057        global $wpdb;
    10581058
     
    10711071     * @covers wpdb::strip_invalid_text_from_query
    10721072     */
    1073     function test_strip_invalid_text_from_query_cp1251_is_safe() {
     1073    public function test_strip_invalid_text_from_query_cp1251_is_safe() {
    10741074        $tablename = 'test_cp1251_query_' . rand_str( 5 );
    10751075        if ( ! self::$_wpdb->query( "CREATE TABLE $tablename ( a VARCHAR(50) ) DEFAULT CHARSET 'cp1251'" ) ) {
     
    10901090     * @covers wpdb::strip_invalid_text_from_query
    10911091     */
    1092     function test_no_db_charset_defined() {
     1092    public function test_no_db_charset_defined() {
    10931093        $tablename = 'test_cp1251_query_' . rand_str( 5 );
    10941094        if ( ! self::$_wpdb->query( "CREATE TABLE $tablename ( a VARCHAR(50) ) DEFAULT CHARSET 'cp1251'" ) ) {
     
    11141114     * @covers wpdb::set_charset
    11151115     */
    1116     function test_set_charset_changes_the_connection_collation() {
     1116    public function test_set_charset_changes_the_connection_collation() {
    11171117        self::$_wpdb->set_charset( self::$_wpdb->dbh, 'utf8', 'utf8_general_ci' );
    11181118        $results = self::$_wpdb->get_results( "SHOW VARIABLES WHERE Variable_name='collation_connection'" );
Note: See TracChangeset for help on using the changeset viewer.