Tests: Update legacy arguments passed to WP_UnitTest_Factory_For_Blog::create_object()
.
This converts the arguments originally meant for `wpmu_create_blog()` to the ones used by `wp_insert_site()`. Follow-up to [47011]. Fixes #47195. git-svn-id: https://develop.svn.wordpress.org/trunk@47013 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
f8051662b1
commit
93eeb8f1d7
@ -33,17 +33,8 @@ class WP_UnitTest_Factory_For_Blog extends WP_UnitTest_Factory_For_Thing {
|
||||
public function create_object( $args ) {
|
||||
global $wpdb;
|
||||
|
||||
// Map some arguments for backward compatibility with wpmu_create_blog() previously used here.
|
||||
if ( ! isset( $args['public'] ) ) {
|
||||
// Default to public, unless an options array was provided.
|
||||
$args['public'] = ! isset( $args['meta'] ) ? 1 : 0;
|
||||
}
|
||||
|
||||
if ( ! isset( $args['user_id'] ) ) {
|
||||
$args['user_id'] = get_current_user_id();
|
||||
}
|
||||
|
||||
if ( isset( $args['site_id'] ) ) {
|
||||
// Map some arguments for backward compatibility with `wpmu_create_blog()` previously used here.
|
||||
if ( ! isset( $args['network_id'] ) && isset( $args['site_id'] ) ) {
|
||||
$args['network_id'] = $args['site_id'];
|
||||
unset( $args['site_id'] );
|
||||
}
|
||||
|
@ -43,23 +43,37 @@ if ( is_multisite() ) :
|
||||
$site_ids = array(
|
||||
'public' => self::factory()->blog->create_many(
|
||||
random_int( 0, 5 ),
|
||||
array( 'meta' => array( 'public' => 1 ) )
|
||||
array(
|
||||
'public' => 1,
|
||||
)
|
||||
),
|
||||
'archived' => self::factory()->blog->create_many(
|
||||
random_int( 0, 5 ),
|
||||
array( 'meta' => array( 'archived' => 1 ) )
|
||||
array(
|
||||
'public' => 0,
|
||||
'archived' => 1,
|
||||
)
|
||||
),
|
||||
'mature' => self::factory()->blog->create_many(
|
||||
random_int( 0, 5 ),
|
||||
array( 'meta' => array( 'mature' => 1 ) )
|
||||
array(
|
||||
'public' => 0,
|
||||
'mature' => 1,
|
||||
)
|
||||
),
|
||||
'spam' => self::factory()->blog->create_many(
|
||||
random_int( 0, 5 ),
|
||||
array( 'meta' => array( 'spam' => 1 ) )
|
||||
array(
|
||||
'public' => 0,
|
||||
'spam' => 1,
|
||||
)
|
||||
),
|
||||
'deleted' => self::factory()->blog->create_many(
|
||||
random_int( 0, 5 ),
|
||||
array( 'meta' => array( 'deleted' => 1 ) )
|
||||
array(
|
||||
'public' => 0,
|
||||
'deleted' => 1,
|
||||
)
|
||||
),
|
||||
);
|
||||
|
||||
|
@ -57,27 +57,27 @@ if ( is_multisite() ) :
|
||||
'wordpress.org/' => array(
|
||||
'domain' => 'wordpress.org',
|
||||
'path' => '/',
|
||||
'site_id' => self::$network_ids['wordpress.org/'],
|
||||
'network_id' => self::$network_ids['wordpress.org/'],
|
||||
),
|
||||
'wordpress.org/foo/' => array(
|
||||
'domain' => 'wordpress.org',
|
||||
'path' => '/foo/',
|
||||
'site_id' => self::$network_ids['wordpress.org/'],
|
||||
'network_id' => self::$network_ids['wordpress.org/'],
|
||||
),
|
||||
'wordpress.org/foo/bar/' => array(
|
||||
'domain' => 'wordpress.org',
|
||||
'path' => '/foo/bar/',
|
||||
'site_id' => self::$network_ids['wordpress.org/'],
|
||||
'network_id' => self::$network_ids['wordpress.org/'],
|
||||
),
|
||||
'make.wordpress.org/' => array(
|
||||
'domain' => 'make.wordpress.org',
|
||||
'path' => '/',
|
||||
'site_id' => self::$network_ids['make.wordpress.org/'],
|
||||
'network_id' => self::$network_ids['make.wordpress.org/'],
|
||||
),
|
||||
'make.wordpress.org/foo/' => array(
|
||||
'domain' => 'make.wordpress.org',
|
||||
'path' => '/foo/',
|
||||
'site_id' => self::$network_ids['make.wordpress.org/'],
|
||||
'network_id' => self::$network_ids['make.wordpress.org/'],
|
||||
),
|
||||
'www.w.org/' => array(
|
||||
'domain' => 'www.w.org',
|
||||
|
@ -33,32 +33,32 @@ if ( is_multisite() ) :
|
||||
'wordpress.org/' => array(
|
||||
'domain' => 'wordpress.org',
|
||||
'path' => '/',
|
||||
'site_id' => self::$network_ids['wordpress.org/'],
|
||||
'network_id' => self::$network_ids['wordpress.org/'],
|
||||
),
|
||||
'foo.wordpress.org/' => array(
|
||||
'domain' => 'foo.wordpress.org',
|
||||
'path' => '/',
|
||||
'site_id' => self::$network_ids['wordpress.org/'],
|
||||
'network_id' => self::$network_ids['wordpress.org/'],
|
||||
),
|
||||
'wordpress.org/foo/' => array(
|
||||
'domain' => 'wordpress.org',
|
||||
'path' => '/foo/',
|
||||
'site_id' => self::$network_ids['wordpress.org/'],
|
||||
'network_id' => self::$network_ids['wordpress.org/'],
|
||||
),
|
||||
'www.wordpress.net/' => array(
|
||||
'domain' => 'www.wordpress.net',
|
||||
'path' => '/',
|
||||
'site_id' => self::$network_ids['www.wordpress.net/'],
|
||||
'network_id' => self::$network_ids['www.wordpress.net/'],
|
||||
),
|
||||
'foo.wordpress.net/' => array(
|
||||
'domain' => 'foo.wordpress.net',
|
||||
'path' => '/',
|
||||
'site_id' => self::$network_ids['www.wordpress.net/'],
|
||||
'network_id' => self::$network_ids['www.wordpress.net/'],
|
||||
),
|
||||
'www.wordpress.net/foo/' => array(
|
||||
'domain' => 'www.wordpress.net',
|
||||
'path' => '/foo/',
|
||||
'site_id' => self::$network_ids['www.wordpress.net/'],
|
||||
'network_id' => self::$network_ids['www.wordpress.net/'],
|
||||
),
|
||||
);
|
||||
|
||||
|
@ -37,12 +37,12 @@ if ( is_multisite() ) :
|
||||
'wordpress.org/' => array(
|
||||
'domain' => 'wordpress.org',
|
||||
'path' => '/',
|
||||
'site_id' => self::$network_ids['wordpress.org/'],
|
||||
'network_id' => self::$network_ids['wordpress.org/'],
|
||||
),
|
||||
'wordpress.org/foo/' => array(
|
||||
'domain' => 'wordpress.org',
|
||||
'path' => '/foo/',
|
||||
'site_id' => self::$network_ids['wordpress.org/'],
|
||||
'network_id' => self::$network_ids['wordpress.org/'],
|
||||
),
|
||||
);
|
||||
|
||||
|
@ -40,17 +40,17 @@ if ( is_multisite() ) :
|
||||
array(
|
||||
'domain' => 'wordpress.org',
|
||||
'path' => '/',
|
||||
'site_id' => self::$different_network_id,
|
||||
'network_id' => self::$different_network_id,
|
||||
),
|
||||
array(
|
||||
'domain' => 'wordpress.org',
|
||||
'path' => '/foo/',
|
||||
'site_id' => self::$different_network_id,
|
||||
'network_id' => self::$different_network_id,
|
||||
),
|
||||
array(
|
||||
'domain' => 'wordpress.org',
|
||||
'path' => '/bar/',
|
||||
'site_id' => self::$different_network_id,
|
||||
'network_id' => self::$different_network_id,
|
||||
),
|
||||
);
|
||||
|
||||
|
@ -46,12 +46,12 @@ if ( is_multisite() ) :
|
||||
'make.wordpress.org/' => array(
|
||||
'domain' => 'make.wordpress.org',
|
||||
'path' => '/',
|
||||
'site_id' => self::$network_ids['make.wordpress.org/'],
|
||||
'network_id' => self::$network_ids['make.wordpress.org/'],
|
||||
),
|
||||
'make.wordpress.org/foo/' => array(
|
||||
'domain' => 'make.wordpress.org',
|
||||
'path' => '/foo/',
|
||||
'site_id' => self::$network_ids['make.wordpress.org/'],
|
||||
'network_id' => self::$network_ids['make.wordpress.org/'],
|
||||
),
|
||||
);
|
||||
|
||||
@ -65,7 +65,7 @@ if ( is_multisite() ) :
|
||||
array(
|
||||
'domain' => 'uninitialized.org',
|
||||
'path' => '/',
|
||||
'site_id' => self::$network_ids['make.wordpress.org/'],
|
||||
'network_id' => self::$network_ids['make.wordpress.org/'],
|
||||
)
|
||||
);
|
||||
add_action( 'wp_initialize_site', 'wp_initialize_site', 10, 2 );
|
||||
|
@ -51,27 +51,27 @@ if ( is_multisite() ) :
|
||||
'wordpress.org/' => array(
|
||||
'domain' => 'wordpress.org',
|
||||
'path' => '/',
|
||||
'site_id' => self::$network_ids['wordpress.org/'],
|
||||
'network_id' => self::$network_ids['wordpress.org/'],
|
||||
),
|
||||
'wordpress.org/foo/' => array(
|
||||
'domain' => 'wordpress.org',
|
||||
'path' => '/foo/',
|
||||
'site_id' => self::$network_ids['wordpress.org/'],
|
||||
'network_id' => self::$network_ids['wordpress.org/'],
|
||||
),
|
||||
'wordpress.org/foo/bar/' => array(
|
||||
'domain' => 'wordpress.org',
|
||||
'path' => '/foo/bar/',
|
||||
'site_id' => self::$network_ids['wordpress.org/'],
|
||||
'network_id' => self::$network_ids['wordpress.org/'],
|
||||
),
|
||||
'make.wordpress.org/' => array(
|
||||
'domain' => 'make.wordpress.org',
|
||||
'path' => '/',
|
||||
'site_id' => self::$network_ids['make.wordpress.org/'],
|
||||
'network_id' => self::$network_ids['make.wordpress.org/'],
|
||||
),
|
||||
'make.wordpress.org/foo/' => array(
|
||||
'domain' => 'make.wordpress.org',
|
||||
'path' => '/foo/',
|
||||
'site_id' => self::$network_ids['make.wordpress.org/'],
|
||||
'network_id' => self::$network_ids['make.wordpress.org/'],
|
||||
),
|
||||
'www.w.org/' => array(
|
||||
'domain' => 'www.w.org',
|
||||
@ -88,11 +88,9 @@ if ( is_multisite() ) :
|
||||
'www.w.org/make/' => array(
|
||||
'domain' => 'www.w.org',
|
||||
'path' => '/make/',
|
||||
'meta' => array(
|
||||
'public' => 1,
|
||||
'lang_id' => 1,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
foreach ( self::$site_ids as &$id ) {
|
||||
|
@ -15,19 +15,19 @@ if ( is_multisite() ) :
|
||||
'w.org/' => array(
|
||||
'domain' => 'w.org',
|
||||
'path' => '/',
|
||||
'site_id' => 2,
|
||||
'network_id' => 2,
|
||||
),
|
||||
'wp.org/' => array(
|
||||
'domain' => 'wp.org',
|
||||
'path' => '/',
|
||||
'site_id' => 2,
|
||||
'meta' => array( 'public' => 0 ),
|
||||
'network_id' => 2,
|
||||
'public' => 0,
|
||||
),
|
||||
'wp.org/foo/' => array(
|
||||
'domain' => 'wp.org',
|
||||
'path' => '/foo/',
|
||||
'site_id' => 1,
|
||||
'meta' => array( 'public' => 0 ),
|
||||
'network_id' => 1,
|
||||
'public' => 0,
|
||||
),
|
||||
'wp.org/oof/' => array(
|
||||
'domain' => 'wp.org',
|
||||
|
@ -36,7 +36,7 @@ if ( is_multisite() ) :
|
||||
array(
|
||||
'domain' => $domain,
|
||||
'path' => $path,
|
||||
'site_id' => $network->id,
|
||||
'network_id' => $network->id,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -104,9 +104,7 @@ if ( is_multisite() ) :
|
||||
$blog_id = self::factory()->blog->create(
|
||||
array(
|
||||
'user_id' => $user_id,
|
||||
'meta' => array(
|
||||
'public' => 1,
|
||||
),
|
||||
)
|
||||
);
|
||||
$this->assertInternalType( 'integer', $blog_id );
|
||||
|
@ -83,7 +83,7 @@ if ( is_multisite() ) :
|
||||
$site_id = self::factory()->blog->create(
|
||||
array(
|
||||
'user_id' => self::$user_id,
|
||||
'meta' => array( 'spam' => 1 ),
|
||||
'spam' => 1,
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -122,15 +122,12 @@ if ( is_multisite() ) :
|
||||
$this->assertTrue( is_blog_user() );
|
||||
$this->assertTrue( is_blog_user( get_current_blog_id() ) );
|
||||
|
||||
$blog_ids = array();
|
||||
$blog_id = self::factory()->blog->create( array( 'user_id' => get_current_user_id() ) );
|
||||
|
||||
$blog_ids = self::factory()->blog->create_many( 1 );
|
||||
foreach ( $blog_ids as $blog_id ) {
|
||||
$this->assertInternalType( 'int', $blog_id );
|
||||
$this->assertTrue( is_blog_user( $blog_id ) );
|
||||
$this->assertTrue( remove_user_from_blog( $user1_id, $blog_id ) );
|
||||
$this->assertFalse( is_blog_user( $blog_id ) );
|
||||
}
|
||||
|
||||
wp_set_current_user( $old_current );
|
||||
}
|
||||
@ -157,8 +154,8 @@ if ( is_multisite() ) :
|
||||
$this->assertTrue( is_user_member_of_blog( $user1_id ) );
|
||||
$this->assertTrue( is_user_member_of_blog( $user1_id, $site_id ) );
|
||||
|
||||
$blog_ids = self::factory()->blog->create_many( 1 );
|
||||
foreach ( $blog_ids as $blog_id ) {
|
||||
$blog_id = self::factory()->blog->create( array( 'user_id' => get_current_user_id() ) );
|
||||
|
||||
$this->assertInternalType( 'int', $blog_id );
|
||||
|
||||
// Current user gets added to new blogs
|
||||
@ -184,7 +181,6 @@ if ( is_multisite() ) :
|
||||
|
||||
$this->assertFalse( is_user_member_of_blog( $user1_id, $blog_id ) );
|
||||
$this->assertTrue( is_user_member_of_blog( $user2_id, $blog_id ) );
|
||||
}
|
||||
|
||||
wpmu_delete_user( $user1_id );
|
||||
$user = new WP_User( $user1_id );
|
||||
|
Loading…
Reference in New Issue
Block a user