From c3dfdf84afd071133fcbb29a570258f95f3b9f3d Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sun, 29 Sep 2019 12:18:48 +0000 Subject: [PATCH] Docs: Improve comments in `tests/multisite/network.php` per the documentation standards. Props garrett-eclipse, jrf. See #48142. git-svn-id: https://develop.svn.wordpress.org/trunk@46342 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/multisite/network.php | 54 +++++++++++------------ 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/tests/phpunit/tests/multisite/network.php b/tests/phpunit/tests/multisite/network.php index 0a5d57cb99..fbfea7a1a4 100644 --- a/tests/phpunit/tests/multisite/network.php +++ b/tests/phpunit/tests/multisite/network.php @@ -152,7 +152,7 @@ if ( is_multisite() ) : $site_count_start = get_blog_count(); $site_ids = self::factory()->blog->create_many( 1 ); - $actual = (int) get_blog_count(); // count only updated when cron runs, so unchanged + $actual = (int) get_blog_count(); // Count only updated when cron runs, so should be unchanged. foreach ( $site_ids as $site_id ) { wpmu_delete_blog( $site_id, true ); @@ -171,7 +171,7 @@ if ( is_multisite() ) : add_filter( 'enable_live_network_counts', '__return_false' ); $site_ids = self::factory()->blog->create_many( 1 ); - $actual = (int) get_blog_count(); // count only updated when cron runs, so unchanged + $actual = (int) get_blog_count(); // Count only updated when cron runs, so should be unchanged. remove_filter( 'enable_live_network_counts', '__return_false' ); foreach ( $site_ids as $site_id ) { @@ -234,16 +234,16 @@ if ( is_multisite() ) : * @ticket 22917 */ function test_enable_live_network_user_counts_filter() { - // false for large networks by default + // False for large networks by default. add_filter( 'enable_live_network_counts', '__return_false' ); - // Refresh the cache + // Refresh the cache. wp_update_network_counts(); $start_count = get_user_count(); wpmu_create_user( 'user', 'pass', 'email' ); - // No change, cache not refreshed + // No change, cache not refreshed. $count = get_user_count(); $this->assertEquals( $start_count, $count ); @@ -265,29 +265,29 @@ if ( is_multisite() ) : function test_active_network_plugins() { $path = 'hello.php'; - // local activate, should be invisible for the network - activate_plugin( $path ); // $network_wide = false + // Local activate, should be invisible for the network. + activate_plugin( $path ); // Enable the plugin for the current site. $active_plugins = wp_get_active_network_plugins(); $this->assertEquals( array(), $active_plugins ); add_action( 'deactivated_plugin', array( $this, '_helper_deactivate_hook' ) ); - // activate the plugin sitewide - activate_plugin( $path, '', $network_wide = true ); + // Activate the plugin sitewide. + activate_plugin( $path, '', $network_wide = true ); // Enable the plugin for all sites in the network. $active_plugins = wp_get_active_network_plugins(); $this->assertEquals( array( WP_PLUGIN_DIR . '/hello.php' ), $active_plugins ); - //deactivate the plugin + // Deactivate the plugin. deactivate_plugins( $path ); $active_plugins = wp_get_active_network_plugins(); $this->assertEquals( array(), $active_plugins ); - $this->assertEquals( 1, $this->plugin_hook_count ); // testing actions and silent mode + $this->assertEquals( 1, $this->plugin_hook_count ); // Testing actions and silent mode. - activate_plugin( $path, '', $network_wide = true ); - deactivate_plugins( $path, true ); // silent + activate_plugin( $path, '', $network_wide = true ); // Enable the plugin for all sites in the network. + deactivate_plugins( $path, true ); // Silent mode. - $this->assertEquals( 1, $this->plugin_hook_count ); // testing actions and silent mode + $this->assertEquals( 1, $this->plugin_hook_count ); // Testing actions and silent mode. } /** @@ -298,14 +298,14 @@ if ( is_multisite() ) : $mock = new MockAction(); add_action( 'activate_' . $path, array( $mock, 'action' ) ); - // should activate on the first try - activate_plugin( $path, '', true ); + // Should activate on the first try. + activate_plugin( $path, '', true ); // Enable the plugin for all sites in the network. $active_plugins = wp_get_active_network_plugins(); $this->assertCount( 1, $active_plugins ); $this->assertEquals( 1, $mock->get_call_count() ); - // should do nothing on the second try - activate_plugin( $path, '', true ); + // Should do nothing on the second try. + activate_plugin( $path, '', true ); // Enable the plugin for all sites in the network. $active_plugins = wp_get_active_network_plugins(); $this->assertCount( 1, $active_plugins ); $this->assertEquals( 1, $mock->get_call_count() ); @@ -328,18 +328,18 @@ if ( is_multisite() ) : } function test_get_user_count() { - // Refresh the cache + // Refresh the cache. wp_update_network_counts(); $start_count = get_user_count(); - // Only false for large networks as of 3.7 + // Only false for large networks as of 3.7. add_filter( 'enable_live_network_counts', '__return_false' ); self::factory()->user->create( array( 'role' => 'administrator' ) ); - $count = get_user_count(); // No change, cache not refreshed + $count = get_user_count(); // No change, cache not refreshed. $this->assertEquals( $start_count, $count ); - wp_update_network_counts(); // Magic happens here + wp_update_network_counts(); // Magic happens here. $count = get_user_count(); $this->assertEquals( $start_count + 1, $count ); @@ -349,7 +349,7 @@ if ( is_multisite() ) : function test_wp_schedule_update_network_counts() { $this->assertFalse( wp_next_scheduled( 'update_network_counts' ) ); - // We can't use wp_schedule_update_network_counts() because WP_INSTALLING is set + // We can't use wp_schedule_update_network_counts() because WP_INSTALLING is set. wp_schedule_event( time(), 'twicedaily', 'update_network_counts' ); $this->assertInternalType( 'int', wp_next_scheduled( 'update_network_counts' ) ); @@ -359,7 +359,7 @@ if ( is_multisite() ) : * @expectedDeprecated get_dashboard_blog */ function test_get_dashboard_blog() { - // if there is no dashboard blog set, current blog is used + // If there is no dashboard blog set, current blog is used. $dashboard_blog = get_dashboard_blog(); $this->assertEquals( 1, $dashboard_blog->blog_id ); @@ -367,7 +367,7 @@ if ( is_multisite() ) : $blog_id = self::factory()->blog->create( array( 'user_id' => $user_id ) ); $this->assertInternalType( 'int', $blog_id ); - // set the dashboard blog to another one + // Set the dashboard blog to another one. update_site_option( 'dashboard_blog', $blog_id ); $dashboard_blog = get_dashboard_blog(); $this->assertEquals( $blog_id, $dashboard_blog->blog_id ); @@ -647,12 +647,12 @@ if ( is_multisite() ) : } /** - * Gets the ID of the site with the highest ID + * Gets the ID of the site with the highest ID. * @return int */ protected function _get_next_network_id() { global $wpdb; - //create an extra network, just to make sure we know the ID of the following one + // Create an extra network, just to make sure we know the ID of the following one. static::factory()->network->create(); return (int) $wpdb->get_var( 'SELECT id FROM ' . $wpdb->site . ' ORDER BY id DESC LIMIT 1' ) + 1; }