* Fill in undefined var in `Tests_Option_BlogOption`
* Add `defined()` check for `BLOGSUPLOADDIR` * Suppress deprecated function notices for `is_blog_user()` and `get_dashboard_blog()` * Check existence of `$user` in `wpmu_log_new_registrations()` before arbitrarily making a database query Fixes all notices in multisite unit tests. See #25282. git-svn-id: https://develop.svn.wordpress.org/trunk@25397 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
cccac649d5
commit
3ae18e68ff
|
@ -1476,7 +1476,8 @@ function update_posts_count( $deprecated = '' ) {
|
|||
function wpmu_log_new_registrations( $blog_id, $user_id ) {
|
||||
global $wpdb;
|
||||
$user = get_userdata( (int) $user_id );
|
||||
$wpdb->insert( $wpdb->registration_log, array('email' => $user->user_email, 'IP' => preg_replace( '/[^0-9., ]/', '', wp_unslash( $_SERVER['REMOTE_ADDR'] ) ), 'blog_id' => $blog_id, 'date_registered' => current_time('mysql')) );
|
||||
if ( $user )
|
||||
$wpdb->insert( $wpdb->registration_log, array('email' => $user->user_email, 'IP' => preg_replace( '/[^0-9., ]/', '', wp_unslash( $_SERVER['REMOTE_ADDR'] ) ), 'blog_id' => $blog_id, 'date_registered' => current_time('mysql')) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -11,6 +11,28 @@ class Tests_MS extends WP_UnitTestCase {
|
|||
|
||||
protected $plugin_hook_count = 0;
|
||||
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$_SERVER['REMOTE_ADDR'] = '';
|
||||
add_action( 'deprecated_function_run', array( $this, 'deprecated_function_run_check' ) );
|
||||
}
|
||||
|
||||
function tearDown() {
|
||||
parent::tearDown();
|
||||
remove_action( 'deprecated_function_run', array( $this, 'deprecated_function_run_check' ) );
|
||||
}
|
||||
|
||||
function deprecated_function_run_check( $function ) {
|
||||
if ( in_array( $function, array( 'is_blog_user', 'get_dashboard_blog' ) ) )
|
||||
add_filter( 'deprecated_function_trigger_error', array( $this, 'filter_deprecated_function_trigger_error' ) );
|
||||
}
|
||||
|
||||
function filter_deprecated_function_trigger_error() {
|
||||
remove_filter( 'deprecated_function_trigger_error', array( $this, 'filter_deprecated_function_trigger_error' ) );
|
||||
return false;
|
||||
}
|
||||
|
||||
function test_create_and_delete_blog() {
|
||||
global $wpdb;
|
||||
|
||||
|
@ -308,7 +330,7 @@ class Tests_MS extends WP_UnitTestCase {
|
|||
$this->assertFalse( upload_is_user_over_quota( $echo ) );
|
||||
$this->assertTrue( is_upload_space_available() );
|
||||
|
||||
if ( ! file_exists( BLOGSUPLOADDIR ) )
|
||||
if ( defined( 'BLOGSUPLOADDIR' ) && ! file_exists( BLOGSUPLOADDIR ) )
|
||||
$this->markTestSkipped( 'This test is broken when blogs.dir does not exist. ');
|
||||
|
||||
/*
|
||||
|
@ -525,7 +547,7 @@ class Tests_MS extends WP_UnitTestCase {
|
|||
|
||||
/**
|
||||
* Test fetching a blog that doesn't exist and again after it exists.
|
||||
*
|
||||
*
|
||||
* @ticket 23405
|
||||
*/
|
||||
function test_get_blog_details_blog_does_not_exist() {
|
||||
|
@ -1013,7 +1035,7 @@ class Tests_MS extends WP_UnitTestCase {
|
|||
'user_login' => $spam_username,
|
||||
) );
|
||||
update_user_status( $spam_user_id, 'spam', '1' );
|
||||
|
||||
|
||||
$this->assertTrue( is_user_spammy( $spam_username ) );
|
||||
$this->assertFalse( is_user_spammy( 'testuser1' ) );
|
||||
}
|
||||
|
|
|
@ -5,6 +5,12 @@ if ( is_multisite() ) :
|
|||
* @group option
|
||||
*/
|
||||
class Tests_Option_BlogOption extends WP_UnitTestCase {
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$_SERVER['REMOTE_ADDR'] = null;
|
||||
}
|
||||
|
||||
function test_from_same_site() {
|
||||
$key = rand_str();
|
||||
$key2 = rand_str();
|
||||
|
@ -81,6 +87,7 @@ class Tests_Option_BlogOption extends WP_UnitTestCase {
|
|||
function test_with_another_site() {
|
||||
global $current_site, $base;
|
||||
|
||||
$title = 'Fooblog';
|
||||
$domain = 'blogoptiontest';
|
||||
|
||||
if ( is_subdomain_install() ) {
|
||||
|
|
Loading…
Reference in New Issue