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/multisite/network.php

    r51869 r52010  
    1515                protected static $different_site_ids = array();
    1616
    17                 function tear_down() {
     17                public function tear_down() {
    1818                        global $current_site;
    1919                        $current_site->id = 1;
    … …  
    6868                 * By default, only one network exists and has a network ID of 1.
    6969                 */
    70                 function test_get_main_network_id_default() {
     70                public function test_get_main_network_id_default() {
    7171                        $this->assertSame( 1, get_main_network_id() );
    7272                }
    … …  
    7676                 * as the main network ID.
    7777                 */
    78                 function test_get_main_network_id_two_networks() {
     78                public function test_get_main_network_id_two_networks() {
    7979                        self::factory()->network->create();
    8080
    … …  
    8686                 * main network should still return as 1.
    8787                 */
    88                 function test_get_main_network_id_after_network_switch() {
     88                public function test_get_main_network_id_after_network_switch() {
    8989                        global $current_site;
    9090
    … …  
    103103                 * fake the process with UPDATE queries.
    104104                 */
    105                 function test_get_main_network_id_after_network_delete() {
     105                public function test_get_main_network_id_after_network_delete() {
    106106                        global $wpdb, $current_site;
    107107
    … …  
    116116                }
    117117
    118                 function test_get_main_network_id_filtered() {
    119                         add_filter( 'get_main_network_id', array( $this, '_get_main_network_id' ) );
     118                public function test_get_main_network_id_filtered() {
     119                        add_filter( 'get_main_network_id', array( $this, 'get_main_network_id' ) );
    120120                        $this->assertSame( 3, get_main_network_id() );
    121                         remove_filter( 'get_main_network_id', array( $this, '_get_main_network_id' ) );
    122                 }
    123 
    124                 function _get_main_network_id() {
     121                        remove_filter( 'get_main_network_id', array( $this, 'get_main_network_id' ) );
     122                }
     123
     124                public function get_main_network_id() {
    125125                        return 3;
    126126                }
    … …  
    129129                 * @ticket 37050
    130130                 */
    131                 function test_wp_network_object_id_property_is_int() {
     131                public function test_wp_network_object_id_property_is_int() {
    132132                        $id = self::factory()->network->create();
    133133
    … …  
    226226                 * @ticket 22917
    227227                 */
    228                 function test_enable_live_network_user_counts_filter() {
     228                public function test_enable_live_network_user_counts_filter() {
    229229                        // False for large networks by default.
    230230                        add_filter( 'enable_live_network_counts', '__return_false' );
    … …  
    255255                }
    256256
    257                 function test_active_network_plugins() {
     257                public function test_active_network_plugins() {
    258258                        $path = 'hello.php';
    259259
    … …  
    263263                        $this->assertSame( array(), $active_plugins );
    264264
    265                         add_action( 'deactivated_plugin', array( $this, '_helper_deactivate_hook' ) );
     265                        add_action( 'deactivated_plugin', array( $this, 'helper_deactivate_hook' ) );
    266266
    267267                        // Activate the plugin sitewide.
    … …  
    286286                 * @ticket 28651
    287287                 */
    288                 function test_duplicate_network_active_plugin() {
     288                public function test_duplicate_network_active_plugin() {
    289289                        $path = 'hello.php';
    290290                        $mock = new MockAction();
    … …  
    306306                }
    307307
    308                 function test_is_plugin_active_for_network_true() {
     308                public function test_is_plugin_active_for_network_true() {
    309309                        activate_plugin( 'hello.php', '', true );
    310310                        $this->assertTrue( is_plugin_active_for_network( 'hello.php' ) );
    311311                }
    312312
    313                 function test_is_plugin_active_for_network_false() {
     313                public function test_is_plugin_active_for_network_false() {
    314314                        deactivate_plugins( 'hello.php', false, true );
    315315                        $this->assertFalse( is_plugin_active_for_network( 'hello.php' ) );
    316316                }
    317317
    318                 function _helper_deactivate_hook() {
     318                public function helper_deactivate_hook() {
    319319                        $this->plugin_hook_count++;
    320320                }
    321321
    322                 function test_get_user_count() {
     322                public function test_get_user_count() {
    323323                        // Refresh the cache.
    324324                        wp_update_network_counts();
    … …  
    339339                }
    340340
    341                 function test_wp_schedule_update_network_counts() {
     341                public function test_wp_schedule_update_network_counts() {
    342342                        $this->assertFalse( wp_next_scheduled( 'update_network_counts' ) );
    343343
    … …  
    351351                 * @expectedDeprecated get_dashboard_blog
    352352                 */
    353                 function test_get_dashboard_blog() {
     353                public function test_get_dashboard_blog() {
    354354                        // If there is no dashboard blog set, current blog is used.
    355355                        $dashboard_blog = get_dashboard_blog();
    … …  
    369369                 * @ticket 37528
    370370                 */
    371                 function test_wp_update_network_site_counts() {
     371                public function test_wp_update_network_site_counts() {
    372372                        update_network_option( null, 'blog_count', 40 );
    373373
    … …  
    391391                 * @ticket 37528
    392392                 */
    393                 function test_wp_update_network_site_counts_on_different_network() {
     393                public function test_wp_update_network_site_counts_on_different_network() {
    394394                        update_network_option( self::$different_network_id, 'blog_count', 40 );
    395395
Note: See TracChangeset for help on using the changeset viewer.