Skip to content
Permalink
Browse files

Docs: Improve comments in `tests/multisite/network.php` per the docum…

…entation standards.

Props garrett-eclipse, jrf.
See #48142.

git-svn-id: https://develop.svn.wordpress.org/trunk@46342 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information...
SergeyBiryukov committed Sep 29, 2019
1 parent 65ec343 commit c3dfdf84afd071133fcbb29a570258f95f3b9f3d
Showing with 27 additions and 27 deletions.
  1. +27 −27 tests/phpunit/tests/multisite/network.php
@@ -152,7 +152,7 @@ public function test_get_blog_count_no_filter_applied() {
$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 @@ public function test_get_blog_count_enable_live_network_counts_false() {
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 @@ public function test_get_user_count_on_different_network() {
* @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 @@ function test_enable_live_network_user_counts_filter() {
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 @@ function test_duplicate_network_active_plugin() {
$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 @@ function _helper_deactivate_hook() {
}
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 @@ function test_get_user_count() {
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,15 +359,15 @@ function test_wp_schedule_update_network_counts() {
* @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 );
$user_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
$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 @@ public function test_get_network_not_found_cache_clear() {
}
/**
* 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;
}

0 comments on commit c3dfdf8

Please sign in to comment.
You can’t perform that action at this time.