mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-12 04:40:26 +00:00
Tests: First pass at using assertSame() instead of assertEquals() in most of the unit tests.
This ensures that not only the return values match the expected results, but also that their type is the same. Going forward, stricter type checking by using `assertSame()` should generally be preferred to `assertEquals()` where appropriate, to make the tests more reliable. Props johnbillion, jrf, SergeyBiryukov. See #38266. git-svn-id: https://develop.svn.wordpress.org/trunk@48937 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -125,7 +125,7 @@ if ( is_multisite() ) :
|
||||
*/
|
||||
function test_get_network_by_path( $expected_key, $domain, $path, $message ) {
|
||||
$network = get_network_by_path( $domain, $path );
|
||||
$this->assertEquals( self::$network_ids[ $expected_key ], $network->id, $message );
|
||||
$this->assertSame( self::$network_ids[ $expected_key ], $network->id, $message );
|
||||
}
|
||||
|
||||
public function data_get_network_by_path() {
|
||||
@@ -161,7 +161,7 @@ if ( is_multisite() ) :
|
||||
|
||||
remove_filter( 'network_by_path_segments_count', '__return_zero' );
|
||||
|
||||
$this->assertEquals( self::$network_ids[ $expected_key ], $network->id, $message );
|
||||
$this->assertSame( self::$network_ids[ $expected_key ], $network->id, $message );
|
||||
}
|
||||
|
||||
public function data_get_network_by_path_with_zero_path_segments() {
|
||||
@@ -186,7 +186,7 @@ if ( is_multisite() ) :
|
||||
$network = get_network_by_path( 'wordpress.org', '/one/b/' );
|
||||
remove_filter( 'network_by_path_segments_count', array( $this, 'filter_network_path_segments' ) );
|
||||
|
||||
$this->assertEquals( self::$network_ids['wordpress.org/one/'], $network->id );
|
||||
$this->assertSame( self::$network_ids['wordpress.org/one/'], $network->id );
|
||||
}
|
||||
|
||||
public function filter_network_path_segments() {
|
||||
|
||||
@@ -125,7 +125,7 @@ if ( is_multisite() ) :
|
||||
}
|
||||
|
||||
$site = get_blog_details( array( 'domain' => 'wordpress.org' ) );
|
||||
$this->assertEquals( self::$site_ids['wordpress.org/'], $site->blog_id );
|
||||
$this->assertSame( self::$site_ids['wordpress.org/'], $site->blog_id );
|
||||
}
|
||||
|
||||
public function test_get_blog_details_with_only_domain_in_fields_subdirectory() {
|
||||
|
||||
@@ -101,7 +101,7 @@ if ( is_multisite() ) :
|
||||
$result = get_id_from_blogname( 'foo' );
|
||||
$current_site = $original_network;
|
||||
|
||||
$this->assertEquals( $expected, $result );
|
||||
$this->assertSame( $expected, $result );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -122,7 +122,7 @@ if ( is_multisite() ) :
|
||||
$result = get_id_from_blogname( 'foo' );
|
||||
$current_site = $original_network;
|
||||
|
||||
$this->assertEquals( $expected, $result );
|
||||
$this->assertSame( $expected, $result );
|
||||
}
|
||||
|
||||
public function test_get_id_from_blogname_invalid_slug() {
|
||||
@@ -134,7 +134,7 @@ if ( is_multisite() ) :
|
||||
$result = get_id_from_blogname( 'bar' );
|
||||
$current_site = $original_network;
|
||||
|
||||
$this->assertEquals( null, $result );
|
||||
$this->assertNull( $result );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ if ( is_multisite() ) :
|
||||
$site = get_site();
|
||||
restore_current_blog();
|
||||
|
||||
$this->assertEquals( self::$site_ids['wordpress.org/foo/'], $site->id );
|
||||
$this->assertSame( self::$site_ids['wordpress.org/foo/'], $site->id );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ if ( is_multisite() ) :
|
||||
delete_option( 'blog_upload_space' );
|
||||
delete_site_option( 'blog_upload_space' );
|
||||
|
||||
$this->assertEquals( 100, get_space_allowed() );
|
||||
$this->assertSame( 100, get_space_allowed() );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,7 +59,7 @@ if ( is_multisite() ) :
|
||||
delete_site_option( 'blog_upload_space' );
|
||||
update_site_option( 'blog_upload_space', 200 );
|
||||
|
||||
$this->assertEquals( 200, get_space_allowed() );
|
||||
$this->assertSame( 200, get_space_allowed() );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,7 +73,7 @@ if ( is_multisite() ) :
|
||||
update_option( 'blog_upload_space', $site_option );
|
||||
update_site_option( 'blog_upload_space', $network_option );
|
||||
|
||||
$this->assertEquals( $expected, get_space_allowed() );
|
||||
$this->assertSame( $expected, get_space_allowed() );
|
||||
}
|
||||
|
||||
public function data_blog_upload_space() {
|
||||
@@ -108,7 +108,7 @@ if ( is_multisite() ) :
|
||||
$space_allowed = get_space_allowed();
|
||||
remove_filter( 'get_space_allowed', array( $this, '_filter_space_allowed' ) );
|
||||
|
||||
$this->assertEquals( 999, $space_allowed );
|
||||
$this->assertSame( 999, $space_allowed );
|
||||
}
|
||||
|
||||
public function _filter_space_allowed() {
|
||||
|
||||
@@ -44,7 +44,7 @@ if ( is_multisite() ) :
|
||||
|
||||
delete_transient( 'dirsize_cache' );
|
||||
|
||||
$this->assertEquals( $size, get_space_used() );
|
||||
$this->assertSame( $size, get_space_used() );
|
||||
$upload_dir = wp_upload_dir();
|
||||
$this->remove_added_uploads();
|
||||
$this->delete_folders( $upload_dir['basedir'] );
|
||||
@@ -79,7 +79,7 @@ if ( is_multisite() ) :
|
||||
|
||||
delete_transient( 'dirsize_cache' );
|
||||
|
||||
$this->assertEquals( $space_used, get_space_used() );
|
||||
$this->assertSame( $space_used, get_space_used() );
|
||||
|
||||
// Switch back to the new site to remove the uploaded file.
|
||||
switch_to_blog( $blog_id );
|
||||
@@ -92,7 +92,7 @@ if ( is_multisite() ) :
|
||||
function test_get_space_used_pre_get_spaced_used_filter() {
|
||||
add_filter( 'pre_get_space_used', array( $this, '_filter_space_used' ) );
|
||||
|
||||
$this->assertEquals( 300, get_space_used() );
|
||||
$this->assertSame( 300, get_space_used() );
|
||||
|
||||
remove_filter( 'pre_get_space_used', array( $this, '_filter_space_used' ) );
|
||||
}
|
||||
|
||||
@@ -40,18 +40,18 @@ if ( is_multisite() ) :
|
||||
$user_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
|
||||
$blog_id2 = self::factory()->blog->create( array( 'user_id' => $user_id ) );
|
||||
$info = wp_upload_dir();
|
||||
$this->assertEquals( 'http://' . $site->domain . '/wp-content/uploads/' . gmstrftime( '%Y/%m' ), $info['url'] );
|
||||
$this->assertEquals( ABSPATH . 'wp-content/uploads/' . gmstrftime( '%Y/%m' ), $info['path'] );
|
||||
$this->assertEquals( gmstrftime( '/%Y/%m' ), $info['subdir'] );
|
||||
$this->assertEquals( '', $info['error'] );
|
||||
$this->assertSame( 'http://' . $site->domain . '/wp-content/uploads/' . gmstrftime( '%Y/%m' ), $info['url'] );
|
||||
$this->assertSame( ABSPATH . 'wp-content/uploads/' . gmstrftime( '%Y/%m' ), $info['path'] );
|
||||
$this->assertSame( gmstrftime( '/%Y/%m' ), $info['subdir'] );
|
||||
$this->assertFalse( $info['error'] );
|
||||
|
||||
switch_to_blog( $blog_id2 );
|
||||
$info2 = wp_upload_dir();
|
||||
$this->assertNotEquals( $info, $info2 );
|
||||
$this->assertEquals( get_option( 'siteurl' ) . '/wp-content/blogs.dir/' . get_current_blog_id() . '/files/' . gmstrftime( '%Y/%m' ), $info2['url'] );
|
||||
$this->assertEquals( ABSPATH . 'wp-content/blogs.dir/' . get_current_blog_id() . '/files/' . gmstrftime( '%Y/%m' ), $info2['path'] );
|
||||
$this->assertEquals( gmstrftime( '/%Y/%m' ), $info2['subdir'] );
|
||||
$this->assertEquals( '', $info2['error'] );
|
||||
$this->assertSame( get_option( 'siteurl' ) . '/wp-content/blogs.dir/' . get_current_blog_id() . '/files/' . gmstrftime( '%Y/%m' ), $info2['url'] );
|
||||
$this->assertSame( ABSPATH . 'wp-content/blogs.dir/' . get_current_blog_id() . '/files/' . gmstrftime( '%Y/%m' ), $info2['path'] );
|
||||
$this->assertSame( gmstrftime( '/%Y/%m' ), $info2['subdir'] );
|
||||
$this->assertFalse( $info2['error'] );
|
||||
restore_current_blog();
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ if ( is_multisite() ) :
|
||||
* By default, only one network exists and has a network ID of 1.
|
||||
*/
|
||||
function test_get_main_network_id_default() {
|
||||
$this->assertEquals( 1, get_main_network_id() );
|
||||
$this->assertSame( 1, get_main_network_id() );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -86,7 +86,7 @@ if ( is_multisite() ) :
|
||||
function test_get_main_network_id_two_networks() {
|
||||
self::factory()->network->create();
|
||||
|
||||
$this->assertEquals( 1, get_main_network_id() );
|
||||
$this->assertSame( 1, get_main_network_id() );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -100,7 +100,7 @@ if ( is_multisite() ) :
|
||||
|
||||
$current_site->id = (int) $id;
|
||||
|
||||
$this->assertEquals( 1, get_main_network_id() );
|
||||
$this->assertSame( 1, get_main_network_id() );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -120,12 +120,12 @@ if ( is_multisite() ) :
|
||||
$main_network_id = get_main_network_id();
|
||||
$wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->site} SET id=1 WHERE id=%d", $temp_id ) );
|
||||
|
||||
$this->assertEquals( self::$different_network_id, $main_network_id );
|
||||
$this->assertSame( self::$different_network_id, $main_network_id );
|
||||
}
|
||||
|
||||
function test_get_main_network_id_filtered() {
|
||||
add_filter( 'get_main_network_id', array( $this, '_get_main_network_id' ) );
|
||||
$this->assertEquals( 3, get_main_network_id() );
|
||||
$this->assertSame( 3, get_main_network_id() );
|
||||
remove_filter( 'get_main_network_id', array( $this, '_get_main_network_id' ) );
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ if ( is_multisite() ) :
|
||||
}
|
||||
wp_update_network_counts();
|
||||
|
||||
$this->assertEquals( $site_count_start + 1, $actual );
|
||||
$this->assertSame( $site_count_start + 1, $actual );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -246,7 +246,7 @@ if ( is_multisite() ) :
|
||||
// No change, cache not refreshed.
|
||||
$count = get_user_count();
|
||||
|
||||
$this->assertEquals( $start_count, $count );
|
||||
$this->assertSame( $start_count, $count );
|
||||
|
||||
wp_update_network_counts();
|
||||
$start_count = get_user_count();
|
||||
@@ -268,26 +268,26 @@ if ( is_multisite() ) :
|
||||
// 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 );
|
||||
$this->assertSame( array(), $active_plugins );
|
||||
|
||||
add_action( 'deactivated_plugin', array( $this, '_helper_deactivate_hook' ) );
|
||||
|
||||
// Activate the plugin sitewide.
|
||||
activate_plugin( $path, '', 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 );
|
||||
$this->assertSame( array( WP_PLUGIN_DIR . '/hello.php' ), $active_plugins );
|
||||
|
||||
// Deactivate the plugin.
|
||||
deactivate_plugins( $path );
|
||||
$active_plugins = wp_get_active_network_plugins();
|
||||
$this->assertEquals( array(), $active_plugins );
|
||||
$this->assertSame( array(), $active_plugins );
|
||||
|
||||
$this->assertEquals( 1, $this->plugin_hook_count ); // Testing actions and silent mode.
|
||||
$this->assertSame( 1, $this->plugin_hook_count ); // Testing actions and silent mode.
|
||||
|
||||
activate_plugin( $path, '', 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->assertSame( 1, $this->plugin_hook_count ); // Testing actions and silent mode.
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -302,13 +302,13 @@ if ( is_multisite() ) :
|
||||
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() );
|
||||
$this->assertSame( 1, $mock->get_call_count() );
|
||||
|
||||
// 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() );
|
||||
$this->assertSame( 1, $mock->get_call_count() );
|
||||
|
||||
remove_action( 'activate_' . $path, array( $mock, 'action' ) );
|
||||
}
|
||||
@@ -337,7 +337,7 @@ if ( is_multisite() ) :
|
||||
self::factory()->user->create( array( 'role' => 'administrator' ) );
|
||||
|
||||
$count = get_user_count(); // No change, cache not refreshed.
|
||||
$this->assertEquals( $start_count, $count );
|
||||
$this->assertSame( $start_count, $count );
|
||||
|
||||
wp_update_network_counts(); // Magic happens here.
|
||||
|
||||
@@ -392,7 +392,7 @@ if ( is_multisite() ) :
|
||||
wp_update_network_site_counts();
|
||||
|
||||
$result = get_blog_count();
|
||||
$this->assertEquals( $expected, $result );
|
||||
$this->assertSame( $expected, $result );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -404,7 +404,7 @@ if ( is_multisite() ) :
|
||||
wp_update_network_site_counts( self::$different_network_id );
|
||||
|
||||
$result = get_blog_count( self::$different_network_id );
|
||||
$this->assertEquals( 3, $result );
|
||||
$this->assertSame( 3, $result );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -420,7 +420,7 @@ if ( is_multisite() ) :
|
||||
wp_update_network_user_counts();
|
||||
|
||||
$result = get_user_count();
|
||||
$this->assertEquals( $expected, $result );
|
||||
$this->assertSame( $expected, $result );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -436,7 +436,7 @@ if ( is_multisite() ) :
|
||||
wp_update_network_user_counts( self::$different_network_id );
|
||||
|
||||
$result = get_user_count( self::$different_network_id );
|
||||
$this->assertEquals( $expected, $result );
|
||||
$this->assertSame( $expected, $result );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -596,7 +596,7 @@ if ( is_multisite() ) :
|
||||
|
||||
wpmu_delete_blog( $site_id, true );
|
||||
|
||||
$this->assertEquals( $original_count + 1, $result );
|
||||
$this->assertSame( $original_count + 1, $result );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -632,12 +632,12 @@ if ( is_multisite() ) :
|
||||
$new_network = $this->factory()->network->create_and_get();
|
||||
|
||||
// Double-check we got the ID of the new network correct.
|
||||
$this->assertEquals( $new_network_id, $new_network->id );
|
||||
$this->assertSame( $new_network_id, $new_network->id );
|
||||
|
||||
// Verify that if we fetch the network now, it's no longer false.
|
||||
$fetched_network = get_network( $new_network_id );
|
||||
$this->assertInstanceOf( 'WP_Network', $fetched_network );
|
||||
$this->assertEquals( $new_network_id, $fetched_network->id );
|
||||
$this->assertSame( $new_network_id, $fetched_network->id );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -70,7 +70,7 @@ if ( is_multisite() ) :
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertEquals( 3, count( $found ) );
|
||||
$this->assertSame( 3, count( $found ) );
|
||||
}
|
||||
|
||||
public function test_wp_network_query_by_network__in_with_order() {
|
||||
@@ -85,7 +85,7 @@ if ( is_multisite() ) :
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertEquals( $expected, $found );
|
||||
$this->assertSame( $expected, $found );
|
||||
|
||||
$found = $q->query(
|
||||
array(
|
||||
@@ -95,7 +95,7 @@ if ( is_multisite() ) :
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertEquals( array_reverse( $expected ), $found );
|
||||
$this->assertSame( array_reverse( $expected ), $found );
|
||||
}
|
||||
|
||||
public function test_wp_network_query_by_network__in_with_single_id() {
|
||||
@@ -138,7 +138,7 @@ if ( is_multisite() ) :
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertEquals( 2, $found );
|
||||
$this->assertSame( 2, $found );
|
||||
}
|
||||
|
||||
public function test_wp_network_query_by_network__not_in_with_single_id() {
|
||||
@@ -435,7 +435,7 @@ if ( is_multisite() ) :
|
||||
self::$network_ids['make.wordpress.org/'],
|
||||
);
|
||||
|
||||
$this->assertEquals( $expected, $found );
|
||||
$this->assertSame( $expected, $found );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -462,7 +462,7 @@ if ( is_multisite() ) :
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertEquals( $number_of_queries, $wpdb->num_queries );
|
||||
$this->assertSame( $number_of_queries, $wpdb->num_queries );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -491,7 +491,7 @@ if ( is_multisite() ) :
|
||||
'count' => true,
|
||||
)
|
||||
);
|
||||
$this->assertEquals( $number_of_queries, $wpdb->num_queries );
|
||||
$this->assertSame( $number_of_queries, $wpdb->num_queries );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -520,7 +520,7 @@ if ( is_multisite() ) :
|
||||
'count' => true,
|
||||
)
|
||||
);
|
||||
$this->assertEquals( $number_of_queries + 1, $wpdb->num_queries );
|
||||
$this->assertSame( $number_of_queries + 1, $wpdb->num_queries );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -546,7 +546,7 @@ if ( is_multisite() ) :
|
||||
$this->assertSame( array( 555 ), $results );
|
||||
|
||||
// Make sure manually setting total_users doesn't get overwritten.
|
||||
$this->assertEquals( 1, $q->found_networks );
|
||||
$this->assertSame( 1, $q->found_networks );
|
||||
}
|
||||
|
||||
public static function filter_networks_pre_query( $networks, $query ) {
|
||||
|
||||
@@ -91,44 +91,44 @@ if ( is_multisite() ) :
|
||||
function test_switch_restore_blog() {
|
||||
global $_wp_switched_stack, $wpdb;
|
||||
|
||||
$this->assertEquals( array(), $_wp_switched_stack );
|
||||
$this->assertSame( array(), $_wp_switched_stack );
|
||||
$this->assertFalse( ms_is_switched() );
|
||||
$current_blog_id = get_current_blog_id();
|
||||
$this->assertInternalType( 'integer', $current_blog_id );
|
||||
|
||||
wp_cache_set( 'switch-test', $current_blog_id, 'switch-test' );
|
||||
$this->assertEquals( $current_blog_id, wp_cache_get( 'switch-test', 'switch-test' ) );
|
||||
$this->assertSame( $current_blog_id, wp_cache_get( 'switch-test', 'switch-test' ) );
|
||||
|
||||
$blog_id = self::factory()->blog->create();
|
||||
|
||||
$cap_key = wp_get_current_user()->cap_key;
|
||||
switch_to_blog( $blog_id );
|
||||
$this->assertNotEquals( $cap_key, wp_get_current_user()->cap_key );
|
||||
$this->assertEquals( array( $current_blog_id ), $_wp_switched_stack );
|
||||
$this->assertSame( array( $current_blog_id ), $_wp_switched_stack );
|
||||
$this->assertTrue( ms_is_switched() );
|
||||
$this->assertEquals( $blog_id, $wpdb->blogid );
|
||||
$this->assertSame( $blog_id, $wpdb->blogid );
|
||||
$this->assertFalse( wp_cache_get( 'switch-test', 'switch-test' ) );
|
||||
wp_cache_set( 'switch-test', $blog_id, 'switch-test' );
|
||||
$this->assertEquals( $blog_id, wp_cache_get( 'switch-test', 'switch-test' ) );
|
||||
$this->assertSame( $blog_id, wp_cache_get( 'switch-test', 'switch-test' ) );
|
||||
|
||||
switch_to_blog( $blog_id );
|
||||
$this->assertEquals( array( $current_blog_id, $blog_id ), $_wp_switched_stack );
|
||||
$this->assertSame( array( $current_blog_id, $blog_id ), $_wp_switched_stack );
|
||||
$this->assertTrue( ms_is_switched() );
|
||||
$this->assertEquals( $blog_id, $wpdb->blogid );
|
||||
$this->assertEquals( $blog_id, wp_cache_get( 'switch-test', 'switch-test' ) );
|
||||
$this->assertSame( $blog_id, $wpdb->blogid );
|
||||
$this->assertSame( $blog_id, wp_cache_get( 'switch-test', 'switch-test' ) );
|
||||
|
||||
restore_current_blog();
|
||||
$this->assertEquals( array( $current_blog_id ), $_wp_switched_stack );
|
||||
$this->assertSame( array( $current_blog_id ), $_wp_switched_stack );
|
||||
$this->assertTrue( ms_is_switched() );
|
||||
$this->assertEquals( $blog_id, $wpdb->blogid );
|
||||
$this->assertEquals( $blog_id, wp_cache_get( 'switch-test', 'switch-test' ) );
|
||||
$this->assertSame( $blog_id, $wpdb->blogid );
|
||||
$this->assertSame( $blog_id, wp_cache_get( 'switch-test', 'switch-test' ) );
|
||||
|
||||
restore_current_blog();
|
||||
$this->assertEquals( $cap_key, wp_get_current_user()->cap_key );
|
||||
$this->assertEquals( $current_blog_id, get_current_blog_id() );
|
||||
$this->assertEquals( array(), $_wp_switched_stack );
|
||||
$this->assertSame( $cap_key, wp_get_current_user()->cap_key );
|
||||
$this->assertSame( $current_blog_id, get_current_blog_id() );
|
||||
$this->assertSame( array(), $_wp_switched_stack );
|
||||
$this->assertFalse( ms_is_switched() );
|
||||
$this->assertEquals( $current_blog_id, wp_cache_get( 'switch-test', 'switch-test' ) );
|
||||
$this->assertSame( $current_blog_id, wp_cache_get( 'switch-test', 'switch-test' ) );
|
||||
|
||||
$this->assertFalse( restore_current_blog() );
|
||||
}
|
||||
@@ -153,11 +153,11 @@ if ( is_multisite() ) :
|
||||
$this->assertEquals( $details, wp_cache_get( $blog_id . 'short', 'blog-details' ) );
|
||||
|
||||
// get_blogaddress_by_name().
|
||||
$this->assertEquals( 'http://' . $details->domain . $details->path, get_blogaddress_by_name( trim( $details->path, '/' ) ) );
|
||||
$this->assertSame( 'http://' . $details->domain . $details->path, get_blogaddress_by_name( trim( $details->path, '/' ) ) );
|
||||
|
||||
// These are empty until get_blog_details() is called with $get_all = true.
|
||||
$this->assertEquals( false, wp_cache_get( $blog_id, 'blog-details' ) );
|
||||
$this->assertEquals( false, wp_cache_get( $key, 'blog-lookup' ) );
|
||||
$this->assertFalse( wp_cache_get( $blog_id, 'blog-details' ) );
|
||||
$this->assertFalse( wp_cache_get( $key, 'blog-lookup' ) );
|
||||
|
||||
// $get_all = true, populate the full blog-details cache and the blog slug lookup cache.
|
||||
$details = get_blog_details( $blog_id, true );
|
||||
@@ -189,7 +189,7 @@ if ( is_multisite() ) :
|
||||
|
||||
// Update the blog count cache to use get_blog_count().
|
||||
wp_update_network_counts();
|
||||
$this->assertEquals( 2, (int) get_blog_count() );
|
||||
$this->assertSame( 2, (int) get_blog_count() );
|
||||
}
|
||||
|
||||
public function test_site_caches_should_invalidate_when_invalidation_is_not_suspended() {
|
||||
@@ -215,7 +215,7 @@ if ( is_multisite() ) :
|
||||
$new_details = get_site( $site_id );
|
||||
wp_suspend_cache_invalidation( $suspend );
|
||||
|
||||
$this->assertEquals( $details->path, $new_details->path );
|
||||
$this->assertSame( $details->path, $new_details->path );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -230,10 +230,10 @@ if ( is_multisite() ) :
|
||||
// Delete the site without forcing a table drop.
|
||||
wpmu_delete_blog( $blog_id, false );
|
||||
|
||||
$this->assertEquals( false, wp_cache_get( $blog_id, 'blog-details' ) );
|
||||
$this->assertEquals( false, wp_cache_get( $blog_id . 'short', 'blog-details' ) );
|
||||
$this->assertEquals( false, wp_cache_get( $key, 'blog-lookup' ) );
|
||||
$this->assertEquals( false, wp_cache_get( $key, 'blog-id-cache' ) );
|
||||
$this->assertFalse( wp_cache_get( $blog_id, 'blog-details' ) );
|
||||
$this->assertFalse( wp_cache_get( $blog_id . 'short', 'blog-details' ) );
|
||||
$this->assertFalse( wp_cache_get( $key, 'blog-lookup' ) );
|
||||
$this->assertFalse( wp_cache_get( $key, 'blog-id-cache' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -271,10 +271,10 @@ if ( is_multisite() ) :
|
||||
// Delete the site and force a table drop.
|
||||
wpmu_delete_blog( $blog_id, true );
|
||||
|
||||
$this->assertEquals( false, wp_cache_get( $blog_id, 'blog-details' ) );
|
||||
$this->assertEquals( false, wp_cache_get( $blog_id . 'short', 'blog-details' ) );
|
||||
$this->assertEquals( false, wp_cache_get( $key, 'blog-lookup' ) );
|
||||
$this->assertEquals( false, wp_cache_get( $key, 'blog-id-cache' ) );
|
||||
$this->assertFalse( wp_cache_get( $blog_id, 'blog-details' ) );
|
||||
$this->assertFalse( wp_cache_get( $blog_id . 'short', 'blog-details' ) );
|
||||
$this->assertFalse( wp_cache_get( $key, 'blog-lookup' ) );
|
||||
$this->assertFalse( wp_cache_get( $key, 'blog-id-cache' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -312,10 +312,10 @@ if ( is_multisite() ) :
|
||||
// Delete the site and force a table drop.
|
||||
wpmu_delete_blog( $blog_id, true );
|
||||
|
||||
$this->assertEquals( false, wp_cache_get( $blog_id, 'blog-details' ) );
|
||||
$this->assertEquals( false, wp_cache_get( $blog_id . 'short', 'blog-details' ) );
|
||||
$this->assertEquals( false, wp_cache_get( $key, 'blog-lookup' ) );
|
||||
$this->assertEquals( false, wp_cache_get( $key, 'blog-id-cache' ) );
|
||||
$this->assertFalse( wp_cache_get( $blog_id, 'blog-details' ) );
|
||||
$this->assertFalse( wp_cache_get( $blog_id . 'short', 'blog-details' ) );
|
||||
$this->assertFalse( wp_cache_get( $key, 'blog-lookup' ) );
|
||||
$this->assertFalse( wp_cache_get( $key, 'blog-id-cache' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -352,7 +352,7 @@ if ( is_multisite() ) :
|
||||
|
||||
// Update the blog count cache to use get_blog_count().
|
||||
wp_update_network_counts();
|
||||
$this->assertEquals( 1, get_blog_count() );
|
||||
$this->assertSame( 1, get_blog_count() );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -366,7 +366,7 @@ if ( is_multisite() ) :
|
||||
|
||||
// Update the blog count cache to use get_blog_count().
|
||||
wp_update_network_counts();
|
||||
$this->assertEquals( 1, get_blog_count() );
|
||||
$this->assertSame( 1, get_blog_count() );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -434,7 +434,7 @@ if ( is_multisite() ) :
|
||||
get_blog_details( $blog_id );
|
||||
|
||||
// When the cache is primed with an invalid site, the value is set to -1.
|
||||
$this->assertEquals( -1, wp_cache_get( $blog_id, 'blog-details' ) );
|
||||
$this->assertSame( -1, wp_cache_get( $blog_id, 'blog-details' ) );
|
||||
|
||||
// Create a site in the invalid site's place.
|
||||
self::factory()->blog->create();
|
||||
@@ -453,7 +453,7 @@ if ( is_multisite() ) :
|
||||
*/
|
||||
function test_update_blog_status() {
|
||||
$result = update_blog_status( 1, 'spam', 0 );
|
||||
$this->assertEquals( 0, $result );
|
||||
$this->assertSame( 0, $result );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -461,7 +461,7 @@ if ( is_multisite() ) :
|
||||
*/
|
||||
function test_update_blog_status_invalid_status() {
|
||||
$result = update_blog_status( 1, 'doesnotexist', 'invalid' );
|
||||
$this->assertEquals( 'invalid', $result );
|
||||
$this->assertSame( 'invalid', $result );
|
||||
}
|
||||
|
||||
function test_update_blog_status_make_ham_blog_action() {
|
||||
@@ -475,15 +475,15 @@ if ( is_multisite() ) :
|
||||
update_blog_status( $blog_id, 'spam', 0 );
|
||||
$blog = get_site( $blog_id );
|
||||
|
||||
$this->assertEquals( '0', $blog->spam );
|
||||
$this->assertEquals( 1, $test_action_counter );
|
||||
$this->assertSame( '0', $blog->spam );
|
||||
$this->assertSame( 1, $test_action_counter );
|
||||
|
||||
// The action should not fire if the status of 'spam' stays the same.
|
||||
update_blog_status( $blog_id, 'spam', 0 );
|
||||
$blog = get_site( $blog_id );
|
||||
|
||||
$this->assertEquals( '0', $blog->spam );
|
||||
$this->assertEquals( 1, $test_action_counter );
|
||||
$this->assertSame( '0', $blog->spam );
|
||||
$this->assertSame( 1, $test_action_counter );
|
||||
|
||||
remove_action( 'make_ham_blog', array( $this, '_action_counter_cb' ), 10 );
|
||||
}
|
||||
@@ -498,15 +498,15 @@ if ( is_multisite() ) :
|
||||
update_blog_status( $blog_id, 'spam', 1 );
|
||||
$blog = get_site( $blog_id );
|
||||
|
||||
$this->assertEquals( '1', $blog->spam );
|
||||
$this->assertEquals( 1, $test_action_counter );
|
||||
$this->assertSame( '1', $blog->spam );
|
||||
$this->assertSame( 1, $test_action_counter );
|
||||
|
||||
// The action should not fire if the status of 'spam' stays the same.
|
||||
update_blog_status( $blog_id, 'spam', 1 );
|
||||
$blog = get_site( $blog_id );
|
||||
|
||||
$this->assertEquals( '1', $blog->spam );
|
||||
$this->assertEquals( 1, $test_action_counter );
|
||||
$this->assertSame( '1', $blog->spam );
|
||||
$this->assertSame( 1, $test_action_counter );
|
||||
|
||||
remove_action( 'make_spam_blog', array( $this, '_action_counter_cb' ), 10 );
|
||||
}
|
||||
@@ -521,15 +521,15 @@ if ( is_multisite() ) :
|
||||
update_blog_status( $blog_id, 'archived', 1 );
|
||||
$blog = get_site( $blog_id );
|
||||
|
||||
$this->assertEquals( '1', $blog->archived );
|
||||
$this->assertEquals( 1, $test_action_counter );
|
||||
$this->assertSame( '1', $blog->archived );
|
||||
$this->assertSame( 1, $test_action_counter );
|
||||
|
||||
// The action should not fire if the status of 'archived' stays the same.
|
||||
update_blog_status( $blog_id, 'archived', 1 );
|
||||
$blog = get_site( $blog_id );
|
||||
|
||||
$this->assertEquals( '1', $blog->archived );
|
||||
$this->assertEquals( 1, $test_action_counter );
|
||||
$this->assertSame( '1', $blog->archived );
|
||||
$this->assertSame( 1, $test_action_counter );
|
||||
|
||||
remove_action( 'archive_blog', array( $this, '_action_counter_cb' ), 10 );
|
||||
}
|
||||
@@ -545,14 +545,14 @@ if ( is_multisite() ) :
|
||||
update_blog_status( $blog_id, 'archived', 0 );
|
||||
$blog = get_site( $blog_id );
|
||||
|
||||
$this->assertEquals( '0', $blog->archived );
|
||||
$this->assertEquals( 1, $test_action_counter );
|
||||
$this->assertSame( '0', $blog->archived );
|
||||
$this->assertSame( 1, $test_action_counter );
|
||||
|
||||
// The action should not fire if the status of 'archived' stays the same.
|
||||
update_blog_status( $blog_id, 'archived', 0 );
|
||||
$blog = get_site( $blog_id );
|
||||
$this->assertEquals( '0', $blog->archived );
|
||||
$this->assertEquals( 1, $test_action_counter );
|
||||
$this->assertSame( '0', $blog->archived );
|
||||
$this->assertSame( 1, $test_action_counter );
|
||||
|
||||
remove_action( 'unarchive_blog', array( $this, '_action_counter_cb' ), 10 );
|
||||
}
|
||||
@@ -567,15 +567,15 @@ if ( is_multisite() ) :
|
||||
update_blog_status( $blog_id, 'deleted', 1 );
|
||||
$blog = get_site( $blog_id );
|
||||
|
||||
$this->assertEquals( '1', $blog->deleted );
|
||||
$this->assertEquals( 1, $test_action_counter );
|
||||
$this->assertSame( '1', $blog->deleted );
|
||||
$this->assertSame( 1, $test_action_counter );
|
||||
|
||||
// The action should not fire if the status of 'deleted' stays the same.
|
||||
update_blog_status( $blog_id, 'deleted', 1 );
|
||||
$blog = get_site( $blog_id );
|
||||
|
||||
$this->assertEquals( '1', $blog->deleted );
|
||||
$this->assertEquals( 1, $test_action_counter );
|
||||
$this->assertSame( '1', $blog->deleted );
|
||||
$this->assertSame( 1, $test_action_counter );
|
||||
|
||||
remove_action( 'make_delete_blog', array( $this, '_action_counter_cb' ), 10 );
|
||||
}
|
||||
@@ -591,15 +591,15 @@ if ( is_multisite() ) :
|
||||
update_blog_status( $blog_id, 'deleted', 0 );
|
||||
$blog = get_site( $blog_id );
|
||||
|
||||
$this->assertEquals( '0', $blog->deleted );
|
||||
$this->assertEquals( 1, $test_action_counter );
|
||||
$this->assertSame( '0', $blog->deleted );
|
||||
$this->assertSame( 1, $test_action_counter );
|
||||
|
||||
// The action should not fire if the status of 'deleted' stays the same.
|
||||
update_blog_status( $blog_id, 'deleted', 0 );
|
||||
$blog = get_site( $blog_id );
|
||||
|
||||
$this->assertEquals( '0', $blog->deleted );
|
||||
$this->assertEquals( 1, $test_action_counter );
|
||||
$this->assertSame( '0', $blog->deleted );
|
||||
$this->assertSame( 1, $test_action_counter );
|
||||
|
||||
remove_action( 'make_undelete_blog', array( $this, '_action_counter_cb' ), 10 );
|
||||
}
|
||||
@@ -614,15 +614,15 @@ if ( is_multisite() ) :
|
||||
update_blog_status( $blog_id, 'mature', 1 );
|
||||
$blog = get_site( $blog_id );
|
||||
|
||||
$this->assertEquals( '1', $blog->mature );
|
||||
$this->assertEquals( 1, $test_action_counter );
|
||||
$this->assertSame( '1', $blog->mature );
|
||||
$this->assertSame( 1, $test_action_counter );
|
||||
|
||||
// The action should not fire if the status of 'mature' stays the same.
|
||||
update_blog_status( $blog_id, 'mature', 1 );
|
||||
$blog = get_site( $blog_id );
|
||||
|
||||
$this->assertEquals( '1', $blog->mature );
|
||||
$this->assertEquals( 1, $test_action_counter );
|
||||
$this->assertSame( '1', $blog->mature );
|
||||
$this->assertSame( 1, $test_action_counter );
|
||||
|
||||
remove_action( 'mature_blog', array( $this, '_action_counter_cb' ), 10 );
|
||||
}
|
||||
@@ -638,15 +638,15 @@ if ( is_multisite() ) :
|
||||
update_blog_status( $blog_id, 'mature', 0 );
|
||||
|
||||
$blog = get_site( $blog_id );
|
||||
$this->assertEquals( '0', $blog->mature );
|
||||
$this->assertEquals( 1, $test_action_counter );
|
||||
$this->assertSame( '0', $blog->mature );
|
||||
$this->assertSame( 1, $test_action_counter );
|
||||
|
||||
// The action should not fire if the status of 'mature' stays the same.
|
||||
update_blog_status( $blog_id, 'mature', 0 );
|
||||
$blog = get_site( $blog_id );
|
||||
|
||||
$this->assertEquals( '0', $blog->mature );
|
||||
$this->assertEquals( 1, $test_action_counter );
|
||||
$this->assertSame( '0', $blog->mature );
|
||||
$this->assertSame( 1, $test_action_counter );
|
||||
|
||||
remove_action( 'unmature_blog', array( $this, '_action_counter_cb' ), 10 );
|
||||
}
|
||||
@@ -661,15 +661,15 @@ if ( is_multisite() ) :
|
||||
update_blog_status( $blog_id, 'public', 0 );
|
||||
|
||||
$blog = get_site( $blog_id );
|
||||
$this->assertEquals( '0', $blog->public );
|
||||
$this->assertEquals( 1, $test_action_counter );
|
||||
$this->assertSame( '0', $blog->public );
|
||||
$this->assertSame( 1, $test_action_counter );
|
||||
|
||||
// The action should not fire if the status of 'mature' stays the same.
|
||||
update_blog_status( $blog_id, 'public', 0 );
|
||||
$blog = get_site( $blog_id );
|
||||
|
||||
$this->assertEquals( '0', $blog->public );
|
||||
$this->assertEquals( 1, $test_action_counter );
|
||||
$this->assertSame( '0', $blog->public );
|
||||
$this->assertSame( 1, $test_action_counter );
|
||||
|
||||
remove_action( 'update_blog_public', array( $this, '_action_counter_cb' ), 10 );
|
||||
}
|
||||
@@ -680,10 +680,10 @@ if ( is_multisite() ) :
|
||||
function test_posts_count() {
|
||||
self::factory()->post->create();
|
||||
$post2 = self::factory()->post->create();
|
||||
$this->assertEquals( 2, get_site()->post_count );
|
||||
$this->assertSame( 2, get_site()->post_count );
|
||||
|
||||
wp_delete_post( $post2 );
|
||||
$this->assertEquals( 1, get_site()->post_count );
|
||||
$this->assertSame( 1, get_site()->post_count );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -692,11 +692,11 @@ if ( is_multisite() ) :
|
||||
function test_blog_details_cache_invalidation() {
|
||||
update_option( 'blogname', 'foo' );
|
||||
$details = get_site( get_current_blog_id() );
|
||||
$this->assertEquals( 'foo', $details->blogname );
|
||||
$this->assertSame( 'foo', $details->blogname );
|
||||
|
||||
update_option( 'blogname', 'bar' );
|
||||
$details = get_site( get_current_blog_id() );
|
||||
$this->assertEquals( 'bar', $details->blogname );
|
||||
$this->assertSame( 'bar', $details->blogname );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -709,8 +709,8 @@ if ( is_multisite() ) :
|
||||
$key = md5( $details->domain . $details->path );
|
||||
|
||||
// Test the original response and cached response for the newly created site.
|
||||
$this->assertEquals( $blog_id, get_blog_id_from_url( $details->domain, $details->path ) );
|
||||
$this->assertEquals( $blog_id, wp_cache_get( $key, 'blog-id-cache' ) );
|
||||
$this->assertSame( $blog_id, get_blog_id_from_url( $details->domain, $details->path ) );
|
||||
$this->assertSame( $blog_id, wp_cache_get( $key, 'blog-id-cache' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -725,7 +725,7 @@ if ( is_multisite() ) :
|
||||
);
|
||||
$details = get_site( $blog_id );
|
||||
|
||||
$this->assertEquals( $blog_id, get_blog_id_from_url( strtoupper( $details->domain ), strtoupper( $details->path ) ) );
|
||||
$this->assertSame( $blog_id, get_blog_id_from_url( strtoupper( $details->domain ), strtoupper( $details->path ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -735,8 +735,8 @@ if ( is_multisite() ) :
|
||||
$blog_id = self::factory()->blog->create( array( 'path' => '/xyz' ) );
|
||||
$details = get_site( $blog_id );
|
||||
|
||||
$this->assertEquals( 0, get_blog_id_from_url( $details->domain, 'foo' ) );
|
||||
$this->assertEquals( -1, wp_cache_get( md5( $details->domain . 'foo' ), 'blog-id-cache' ) );
|
||||
$this->assertSame( 0, get_blog_id_from_url( $details->domain, 'foo' ) );
|
||||
$this->assertSame( -1, wp_cache_get( md5( $details->domain . 'foo' ), 'blog-id-cache' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -749,8 +749,8 @@ if ( is_multisite() ) :
|
||||
$key = md5( $details->domain . $details->path );
|
||||
wpmu_delete_blog( $blog_id );
|
||||
|
||||
$this->assertEquals( $blog_id, get_blog_id_from_url( $details->domain, $details->path ) );
|
||||
$this->assertEquals( $blog_id, wp_cache_get( $key, 'blog-id-cache' ) );
|
||||
$this->assertSame( $blog_id, get_blog_id_from_url( $details->domain, $details->path ) );
|
||||
$this->assertSame( $blog_id, wp_cache_get( $key, 'blog-id-cache' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -763,9 +763,9 @@ if ( is_multisite() ) :
|
||||
$key = md5( $details->domain . $details->path );
|
||||
wpmu_delete_blog( $blog_id, true );
|
||||
|
||||
$this->assertEquals( false, wp_cache_get( $key, 'blog-id-cache' ) );
|
||||
$this->assertEquals( 0, get_blog_id_from_url( $details->domain, $details->path ) );
|
||||
$this->assertEquals( -1, wp_cache_get( $key, 'blog-id-cache' ) );
|
||||
$this->assertFalse( wp_cache_get( $key, 'blog-id-cache' ) );
|
||||
$this->assertSame( 0, get_blog_id_from_url( $details->domain, $details->path ) );
|
||||
$this->assertSame( -1, wp_cache_get( $key, 'blog-id-cache' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -810,26 +810,26 @@ if ( is_multisite() ) :
|
||||
$site = get_current_site();
|
||||
|
||||
$info = wp_upload_dir();
|
||||
$this->assertEquals( 'http://' . $site->domain . '/wp-content/uploads/' . gmstrftime( '%Y/%m' ), $info['url'] );
|
||||
$this->assertEquals( ABSPATH . 'wp-content/uploads/' . gmstrftime( '%Y/%m' ), $info['path'] );
|
||||
$this->assertEquals( gmstrftime( '/%Y/%m' ), $info['subdir'] );
|
||||
$this->assertEquals( '', $info['error'] );
|
||||
$this->assertSame( 'http://' . $site->domain . '/wp-content/uploads/' . gmstrftime( '%Y/%m' ), $info['url'] );
|
||||
$this->assertSame( ABSPATH . 'wp-content/uploads/' . gmstrftime( '%Y/%m' ), $info['path'] );
|
||||
$this->assertSame( gmstrftime( '/%Y/%m' ), $info['subdir'] );
|
||||
$this->assertFalse( $info['error'] );
|
||||
|
||||
$blog_id = self::factory()->blog->create();
|
||||
|
||||
switch_to_blog( $blog_id );
|
||||
$info = wp_upload_dir();
|
||||
$this->assertEquals( 'http://' . $site->domain . '/wp-content/uploads/sites/' . get_current_blog_id() . '/' . gmstrftime( '%Y/%m' ), $info['url'] );
|
||||
$this->assertEquals( ABSPATH . 'wp-content/uploads/sites/' . get_current_blog_id() . '/' . gmstrftime( '%Y/%m' ), $info['path'] );
|
||||
$this->assertEquals( gmstrftime( '/%Y/%m' ), $info['subdir'] );
|
||||
$this->assertEquals( '', $info['error'] );
|
||||
$this->assertSame( 'http://' . $site->domain . '/wp-content/uploads/sites/' . get_current_blog_id() . '/' . gmstrftime( '%Y/%m' ), $info['url'] );
|
||||
$this->assertSame( ABSPATH . 'wp-content/uploads/sites/' . get_current_blog_id() . '/' . gmstrftime( '%Y/%m' ), $info['path'] );
|
||||
$this->assertSame( gmstrftime( '/%Y/%m' ), $info['subdir'] );
|
||||
$this->assertFalse( $info['error'] );
|
||||
restore_current_blog();
|
||||
|
||||
$info = wp_upload_dir();
|
||||
$this->assertEquals( 'http://' . $site->domain . '/wp-content/uploads/' . gmstrftime( '%Y/%m' ), $info['url'] );
|
||||
$this->assertEquals( ABSPATH . 'wp-content/uploads/' . gmstrftime( '%Y/%m' ), $info['path'] );
|
||||
$this->assertEquals( gmstrftime( '/%Y/%m' ), $info['subdir'] );
|
||||
$this->assertEquals( '', $info['error'] );
|
||||
$this->assertSame( 'http://' . $site->domain . '/wp-content/uploads/' . gmstrftime( '%Y/%m' ), $info['url'] );
|
||||
$this->assertSame( ABSPATH . 'wp-content/uploads/' . gmstrftime( '%Y/%m' ), $info['path'] );
|
||||
$this->assertSame( gmstrftime( '/%Y/%m' ), $info['subdir'] );
|
||||
$this->assertFalse( $info['error'] );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -879,13 +879,13 @@ if ( is_multisite() ) :
|
||||
function test_domain_exists_with_default_site_id() {
|
||||
$details = get_site( 1 );
|
||||
|
||||
$this->assertEquals( 1, domain_exists( $details->domain, $details->path ) );
|
||||
$this->assertSame( 1, domain_exists( $details->domain, $details->path ) );
|
||||
}
|
||||
|
||||
function test_domain_exists_with_specified_site_id() {
|
||||
$details = get_site( 1 );
|
||||
|
||||
$this->assertEquals( 1, domain_exists( $details->domain, $details->path, $details->site_id ) );
|
||||
$this->assertSame( 1, domain_exists( $details->domain, $details->path, $details->site_id ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -895,18 +895,18 @@ if ( is_multisite() ) :
|
||||
function test_domain_does_not_exist_with_invalid_site_id() {
|
||||
$details = get_site( 1 );
|
||||
|
||||
$this->assertEquals( null, domain_exists( $details->domain, $details->path, 999 ) );
|
||||
$this->assertNull( domain_exists( $details->domain, $details->path, 999 ) );
|
||||
}
|
||||
|
||||
function test_invalid_domain_does_not_exist_with_default_site_id() {
|
||||
$this->assertEquals( null, domain_exists( 'foo', 'bar' ) );
|
||||
$this->assertNull( domain_exists( 'foo', 'bar' ) );
|
||||
}
|
||||
|
||||
function test_domain_filtered_to_exist() {
|
||||
add_filter( 'domain_exists', array( $this, '_domain_exists_cb' ), 10, 4 );
|
||||
$exists = domain_exists( 'foo', 'bar' );
|
||||
remove_filter( 'domain_exists', array( $this, '_domain_exists_cb' ), 10, 4 );
|
||||
$this->assertEquals( 1234, $exists );
|
||||
$this->assertSame( 1234, $exists );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -920,7 +920,7 @@ if ( is_multisite() ) :
|
||||
remove_filter( 'domain_exists', array( $this, '_domain_exists_cb' ), 10, 4 );
|
||||
|
||||
// Make sure the same result is returned with or without a trailing slash.
|
||||
$this->assertEquals( $exists1, $exists2 );
|
||||
$this->assertSame( $exists1, $exists2 );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -928,7 +928,7 @@ if ( is_multisite() ) :
|
||||
*/
|
||||
function test_get_blogaddress_by_id_with_valid_id() {
|
||||
$blogaddress = get_blogaddress_by_id( 1 );
|
||||
$this->assertEquals( 'http://' . WP_TESTS_DOMAIN . '/', $blogaddress );
|
||||
$this->assertSame( 'http://' . WP_TESTS_DOMAIN . '/', $blogaddress );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -936,7 +936,7 @@ if ( is_multisite() ) :
|
||||
*/
|
||||
function test_get_blogaddress_by_id_with_invalid_id() {
|
||||
$blogaddress = get_blogaddress_by_id( 42 );
|
||||
$this->assertEquals( '', $blogaddress );
|
||||
$this->assertSame( '', $blogaddress );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1180,7 +1180,7 @@ if ( is_multisite() ) :
|
||||
$old_count = did_action( 'clean_site_cache' );
|
||||
|
||||
clean_blog_cache( $site );
|
||||
$this->assertEquals( $old_count + 1, did_action( 'clean_site_cache' ) );
|
||||
$this->assertSame( $old_count + 1, did_action( 'clean_site_cache' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1194,7 +1194,7 @@ if ( is_multisite() ) :
|
||||
$suspend = wp_suspend_cache_invalidation();
|
||||
clean_blog_cache( $site );
|
||||
wp_suspend_cache_invalidation( $suspend );
|
||||
$this->assertEquals( $old_count, did_action( 'clean_site_cache' ) );
|
||||
$this->assertSame( $old_count, did_action( 'clean_site_cache' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1204,7 +1204,7 @@ if ( is_multisite() ) :
|
||||
$old_count = did_action( 'clean_site_cache' );
|
||||
|
||||
clean_blog_cache( null );
|
||||
$this->assertEquals( $old_count, did_action( 'clean_site_cache' ) );
|
||||
$this->assertSame( $old_count, did_action( 'clean_site_cache' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1214,7 +1214,7 @@ if ( is_multisite() ) :
|
||||
$old_count = did_action( 'clean_site_cache' );
|
||||
|
||||
clean_blog_cache( 'something' );
|
||||
$this->assertEquals( $old_count, did_action( 'clean_site_cache' ) );
|
||||
$this->assertSame( $old_count, did_action( 'clean_site_cache' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1443,7 +1443,7 @@ if ( is_multisite() ) :
|
||||
} elseif ( 'last_updated' === $key ) {
|
||||
$this->assertTrue( $old_site->last_updated <= $value );
|
||||
} else {
|
||||
$this->assertEquals( $old_site->$key, $value );
|
||||
$this->assertSame( $old_site->$key, $value );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1540,7 +1540,7 @@ if ( is_multisite() ) :
|
||||
$result = wp_delete_site( $site_id );
|
||||
|
||||
$this->assertInstanceOf( 'WP_Site', $result );
|
||||
$this->assertEquals( $result->to_array(), $site->to_array() );
|
||||
$this->assertSame( $result->to_array(), $site->to_array() );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2116,8 +2116,8 @@ if ( is_multisite() ) :
|
||||
|
||||
$this->assertTrue( $result );
|
||||
$this->assertTrue( $initialized );
|
||||
$this->assertEquals( $expected_options, $options );
|
||||
$this->assertEquals( $expected_meta, $meta );
|
||||
$this->assertSame( $expected_options, $options );
|
||||
$this->assertSame( $expected_meta, $meta );
|
||||
}
|
||||
|
||||
public function data_wp_initialize_site() {
|
||||
@@ -2214,7 +2214,7 @@ if ( is_multisite() ) :
|
||||
|
||||
$this->assertTrue( $result );
|
||||
$this->assertTrue( $user_is_admin );
|
||||
$this->assertEquals( get_userdata( 1 )->user_email, $admin_email );
|
||||
$this->assertSame( get_userdata( 1 )->user_email, $admin_email );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2370,8 +2370,8 @@ if ( is_multisite() ) :
|
||||
|
||||
// Should not hit blog_details cache initialised in $this->populate_options_callback tirggered during
|
||||
// populate_options callback's call of get_blog_details.
|
||||
$this->assertEquals( 'http://testsite1.example.org/test', get_blog_details( $blog_id )->siteurl );
|
||||
$this->assertEquals( 'http://testsite1.example.org/test', get_site( $blog_id )->siteurl );
|
||||
$this->assertSame( 'http://testsite1.example.org/test', get_blog_details( $blog_id )->siteurl );
|
||||
$this->assertSame( 'http://testsite1.example.org/test', get_site( $blog_id )->siteurl );
|
||||
|
||||
remove_action( 'populate_options', array( $this, 'populate_options_callback' ) );
|
||||
}
|
||||
|
||||
@@ -186,13 +186,13 @@ if ( is_multisite() ) :
|
||||
add_site_meta( self::$site_id, 'unique_delete_by_key', 'value', true );
|
||||
add_site_meta( self::$site_id2, 'unique_delete_by_key', 'value', true );
|
||||
|
||||
$this->assertEquals( 'value', get_site_meta( self::$site_id, 'unique_delete_by_key', true ) );
|
||||
$this->assertEquals( 'value', get_site_meta( self::$site_id2, 'unique_delete_by_key', true ) );
|
||||
$this->assertSame( 'value', get_site_meta( self::$site_id, 'unique_delete_by_key', true ) );
|
||||
$this->assertSame( 'value', get_site_meta( self::$site_id2, 'unique_delete_by_key', true ) );
|
||||
|
||||
$this->assertTrue( delete_site_meta_by_key( 'unique_delete_by_key' ) );
|
||||
|
||||
$this->assertEquals( '', get_site_meta( self::$site_id, 'unique_delete_by_key', true ) );
|
||||
$this->assertEquals( '', get_site_meta( self::$site_id2, 'unique_delete_by_key', true ) );
|
||||
$this->assertSame( '', get_site_meta( self::$site_id, 'unique_delete_by_key', true ) );
|
||||
$this->assertSame( '', get_site_meta( self::$site_id2, 'unique_delete_by_key', true ) );
|
||||
}
|
||||
|
||||
public function test_site_meta_should_be_deleted_when_site_is_deleted() {
|
||||
|
||||
@@ -135,7 +135,7 @@ if ( is_multisite() ) :
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertEquals( 3, count( $found ) );
|
||||
$this->assertSame( 3, count( $found ) );
|
||||
}
|
||||
|
||||
public function test_wp_site_query_by_site__in_with_single_id() {
|
||||
@@ -181,7 +181,7 @@ if ( is_multisite() ) :
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertEquals( 2, $found );
|
||||
$this->assertSame( 2, $found );
|
||||
}
|
||||
|
||||
public function test_wp_site_query_by_site__not_in_with_single_id() {
|
||||
@@ -237,7 +237,7 @@ if ( is_multisite() ) :
|
||||
self::$site_ids['wordpress.org/foo/bar/'],
|
||||
);
|
||||
|
||||
$this->assertEquals( $expected, $found );
|
||||
$this->assertSame( $expected, $found );
|
||||
|
||||
$found = $q->query(
|
||||
array(
|
||||
@@ -248,7 +248,7 @@ if ( is_multisite() ) :
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertEquals( array_reverse( $expected ), $found );
|
||||
$this->assertSame( array_reverse( $expected ), $found );
|
||||
}
|
||||
|
||||
public function test_wp_site_query_by_network_id_with_existing_sites() {
|
||||
@@ -698,7 +698,7 @@ if ( is_multisite() ) :
|
||||
self::$site_ids['make.wordpress.org/foo/'],
|
||||
);
|
||||
|
||||
$this->assertEquals( $expected, $found );
|
||||
$this->assertSame( $expected, $found );
|
||||
}
|
||||
|
||||
public function test_wp_site_query_by_search_with_text_in_path_exclude_domain_from_search() {
|
||||
@@ -715,7 +715,7 @@ if ( is_multisite() ) :
|
||||
self::$site_ids['www.w.org/make/'],
|
||||
);
|
||||
|
||||
$this->assertEquals( $expected, $found );
|
||||
$this->assertSame( $expected, $found );
|
||||
}
|
||||
|
||||
public function test_wp_site_query_by_search_with_text_in_domain_exclude_path_from_search() {
|
||||
@@ -733,7 +733,7 @@ if ( is_multisite() ) :
|
||||
self::$site_ids['make.wordpress.org/foo/'],
|
||||
);
|
||||
|
||||
$this->assertEquals( $expected, $found );
|
||||
$this->assertSame( $expected, $found );
|
||||
}
|
||||
|
||||
public function test_wp_site_query_by_search_with_wildcard_in_text() {
|
||||
@@ -814,7 +814,7 @@ if ( is_multisite() ) :
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertEquals( $number_of_queries, $wpdb->num_queries );
|
||||
$this->assertSame( $number_of_queries, $wpdb->num_queries );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -844,7 +844,7 @@ if ( is_multisite() ) :
|
||||
'count' => true,
|
||||
)
|
||||
);
|
||||
$this->assertEquals( $number_of_queries, $wpdb->num_queries );
|
||||
$this->assertSame( $number_of_queries, $wpdb->num_queries );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -874,7 +874,7 @@ if ( is_multisite() ) :
|
||||
'count' => true,
|
||||
)
|
||||
);
|
||||
$this->assertEquals( $number_of_queries + 1, $wpdb->num_queries );
|
||||
$this->assertSame( $number_of_queries + 1, $wpdb->num_queries );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -903,7 +903,7 @@ if ( is_multisite() ) :
|
||||
}
|
||||
|
||||
if ( $strict ) {
|
||||
$this->assertEquals( $expected, $found );
|
||||
$this->assertSame( $expected, $found );
|
||||
} else {
|
||||
$this->assertEqualSets( $expected, $found );
|
||||
}
|
||||
@@ -933,7 +933,7 @@ if ( is_multisite() ) :
|
||||
$this->assertSame( array( 555 ), $results );
|
||||
|
||||
// Make sure manually setting total_users doesn't get overwritten.
|
||||
$this->assertEquals( 1, $q->found_sites );
|
||||
$this->assertSame( 1, $q->found_sites );
|
||||
}
|
||||
|
||||
public static function filter_sites_pre_query( $sites, $query ) {
|
||||
|
||||
@@ -39,9 +39,9 @@ if ( is_multisite() ) :
|
||||
|
||||
$blog = get_site( $blog_id );
|
||||
|
||||
$this->assertEquals( 'example.com', $blog->domain );
|
||||
$this->assertEquals( '/my_path/', $blog->path );
|
||||
$this->assertEquals( '0', $blog->spam );
|
||||
$this->assertSame( 'example.com', $blog->domain );
|
||||
$this->assertSame( '/my_path/', $blog->path );
|
||||
$this->assertSame( '0', $blog->spam );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,16 +71,16 @@ if ( is_multisite() ) :
|
||||
update_blog_details( $blog_id, array( $flag => $flag_value ) );
|
||||
$blog = get_site( $blog_id );
|
||||
|
||||
$this->assertEquals( $flag_value, $blog->{$flag} );
|
||||
$this->assertSame( $flag_value, $blog->{$flag} );
|
||||
|
||||
// The hook attached to this flag should have fired once during update_blog_details().
|
||||
$this->assertEquals( 1, $test_action_counter );
|
||||
$this->assertSame( 1, $test_action_counter );
|
||||
|
||||
// Update the site to the exact same flag value for this flag.
|
||||
update_blog_details( $blog_id, array( $flag => $flag_value ) );
|
||||
|
||||
// The hook attached to this flag should not have fired again.
|
||||
$this->assertEquals( 1, $test_action_counter );
|
||||
$this->assertSame( 1, $test_action_counter );
|
||||
|
||||
remove_action( $hook, array( $this, '_action_counter_cb' ), 10 );
|
||||
}
|
||||
@@ -116,7 +116,7 @@ if ( is_multisite() ) :
|
||||
update_blog_details( 1, array( 'path' => $path ) );
|
||||
$site = get_site( 1 );
|
||||
|
||||
$this->assertEquals( $expected, $site->path );
|
||||
$this->assertSame( $expected, $site->path );
|
||||
}
|
||||
|
||||
public function data_single_directory_path() {
|
||||
|
||||
@@ -72,7 +72,7 @@ if ( is_multisite() ) :
|
||||
|
||||
$missing_keys = array_diff_key( array_flip( $keys ), $sites[0] );
|
||||
|
||||
$this->assertEquals( array(), $missing_keys, 'Keys are missing from site arrays.' );
|
||||
$this->assertSame( array(), $missing_keys, 'Keys are missing from site arrays.' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -76,8 +76,8 @@ if ( is_multisite() ) :
|
||||
|
||||
wp_delete_site( $blog_id );
|
||||
|
||||
$this->assertEquals( 'Some page content', $first_page->post_content );
|
||||
$this->assertEquals( 'Some comment content', $first_comment[0]->comment_content );
|
||||
$this->assertSame( 'Some page content', $first_page->post_content );
|
||||
$this->assertSame( 'Some comment content', $first_comment[0]->comment_content );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user