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,
|
||||
)
|
||||
),
|
||||
);
|
||||
|
||||
|
@ -55,29 +55,29 @@ if ( is_multisite() ) :
|
||||
|
||||
self::$site_ids = array(
|
||||
'wordpress.org/' => array(
|
||||
'domain' => 'wordpress.org',
|
||||
'path' => '/',
|
||||
'site_id' => self::$network_ids['wordpress.org/'],
|
||||
'domain' => 'wordpress.org',
|
||||
'path' => '/',
|
||||
'network_id' => self::$network_ids['wordpress.org/'],
|
||||
),
|
||||
'wordpress.org/foo/' => array(
|
||||
'domain' => 'wordpress.org',
|
||||
'path' => '/foo/',
|
||||
'site_id' => self::$network_ids['wordpress.org/'],
|
||||
'domain' => 'wordpress.org',
|
||||
'path' => '/foo/',
|
||||
'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/'],
|
||||
'domain' => 'wordpress.org',
|
||||
'path' => '/foo/bar/',
|
||||
'network_id' => self::$network_ids['wordpress.org/'],
|
||||
),
|
||||
'make.wordpress.org/' => array(
|
||||
'domain' => 'make.wordpress.org',
|
||||
'path' => '/',
|
||||
'site_id' => self::$network_ids['make.wordpress.org/'],
|
||||
'domain' => 'make.wordpress.org',
|
||||
'path' => '/',
|
||||
'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/'],
|
||||
'domain' => 'make.wordpress.org',
|
||||
'path' => '/foo/',
|
||||
'network_id' => self::$network_ids['make.wordpress.org/'],
|
||||
),
|
||||
'www.w.org/' => array(
|
||||
'domain' => 'www.w.org',
|
||||
|
@ -31,34 +31,34 @@ if ( is_multisite() ) :
|
||||
|
||||
self::$site_ids = array(
|
||||
'wordpress.org/' => array(
|
||||
'domain' => 'wordpress.org',
|
||||
'path' => '/',
|
||||
'site_id' => self::$network_ids['wordpress.org/'],
|
||||
'domain' => 'wordpress.org',
|
||||
'path' => '/',
|
||||
'network_id' => self::$network_ids['wordpress.org/'],
|
||||
),
|
||||
'foo.wordpress.org/' => array(
|
||||
'domain' => 'foo.wordpress.org',
|
||||
'path' => '/',
|
||||
'site_id' => self::$network_ids['wordpress.org/'],
|
||||
'domain' => 'foo.wordpress.org',
|
||||
'path' => '/',
|
||||
'network_id' => self::$network_ids['wordpress.org/'],
|
||||
),
|
||||
'wordpress.org/foo/' => array(
|
||||
'domain' => 'wordpress.org',
|
||||
'path' => '/foo/',
|
||||
'site_id' => self::$network_ids['wordpress.org/'],
|
||||
'domain' => 'wordpress.org',
|
||||
'path' => '/foo/',
|
||||
'network_id' => self::$network_ids['wordpress.org/'],
|
||||
),
|
||||
'www.wordpress.net/' => array(
|
||||
'domain' => 'www.wordpress.net',
|
||||
'path' => '/',
|
||||
'site_id' => self::$network_ids['www.wordpress.net/'],
|
||||
'domain' => 'www.wordpress.net',
|
||||
'path' => '/',
|
||||
'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/'],
|
||||
'domain' => 'foo.wordpress.net',
|
||||
'path' => '/',
|
||||
'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/'],
|
||||
'domain' => 'www.wordpress.net',
|
||||
'path' => '/foo/',
|
||||
'network_id' => self::$network_ids['www.wordpress.net/'],
|
||||
),
|
||||
);
|
||||
|
||||
|
@ -35,14 +35,14 @@ if ( is_multisite() ) :
|
||||
'path' => '/',
|
||||
),
|
||||
'wordpress.org/' => array(
|
||||
'domain' => 'wordpress.org',
|
||||
'path' => '/',
|
||||
'site_id' => self::$network_ids['wordpress.org/'],
|
||||
'domain' => 'wordpress.org',
|
||||
'path' => '/',
|
||||
'network_id' => self::$network_ids['wordpress.org/'],
|
||||
),
|
||||
'wordpress.org/foo/' => array(
|
||||
'domain' => 'wordpress.org',
|
||||
'path' => '/foo/',
|
||||
'site_id' => self::$network_ids['wordpress.org/'],
|
||||
'domain' => 'wordpress.org',
|
||||
'path' => '/foo/',
|
||||
'network_id' => self::$network_ids['wordpress.org/'],
|
||||
),
|
||||
);
|
||||
|
||||
|
@ -38,19 +38,19 @@ if ( is_multisite() ) :
|
||||
|
||||
$sites = array(
|
||||
array(
|
||||
'domain' => 'wordpress.org',
|
||||
'path' => '/',
|
||||
'site_id' => self::$different_network_id,
|
||||
'domain' => 'wordpress.org',
|
||||
'path' => '/',
|
||||
'network_id' => self::$different_network_id,
|
||||
),
|
||||
array(
|
||||
'domain' => 'wordpress.org',
|
||||
'path' => '/foo/',
|
||||
'site_id' => self::$different_network_id,
|
||||
'domain' => 'wordpress.org',
|
||||
'path' => '/foo/',
|
||||
'network_id' => self::$different_network_id,
|
||||
),
|
||||
array(
|
||||
'domain' => 'wordpress.org',
|
||||
'path' => '/bar/',
|
||||
'site_id' => self::$different_network_id,
|
||||
'domain' => 'wordpress.org',
|
||||
'path' => '/bar/',
|
||||
'network_id' => self::$different_network_id,
|
||||
),
|
||||
);
|
||||
|
||||
|
@ -44,14 +44,14 @@ if ( is_multisite() ) :
|
||||
|
||||
self::$site_ids = array(
|
||||
'make.wordpress.org/' => array(
|
||||
'domain' => 'make.wordpress.org',
|
||||
'path' => '/',
|
||||
'site_id' => self::$network_ids['make.wordpress.org/'],
|
||||
'domain' => 'make.wordpress.org',
|
||||
'path' => '/',
|
||||
'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/'],
|
||||
'domain' => 'make.wordpress.org',
|
||||
'path' => '/foo/',
|
||||
'network_id' => self::$network_ids['make.wordpress.org/'],
|
||||
),
|
||||
);
|
||||
|
||||
@ -63,9 +63,9 @@ if ( is_multisite() ) :
|
||||
remove_action( 'wp_initialize_site', 'wp_initialize_site', 10 );
|
||||
self::$uninitialized_site_id = wp_insert_site(
|
||||
array(
|
||||
'domain' => 'uninitialized.org',
|
||||
'path' => '/',
|
||||
'site_id' => self::$network_ids['make.wordpress.org/'],
|
||||
'domain' => 'uninitialized.org',
|
||||
'path' => '/',
|
||||
'network_id' => self::$network_ids['make.wordpress.org/'],
|
||||
)
|
||||
);
|
||||
add_action( 'wp_initialize_site', 'wp_initialize_site', 10, 2 );
|
||||
|
@ -49,29 +49,29 @@ if ( is_multisite() ) :
|
||||
|
||||
self::$site_ids = array(
|
||||
'wordpress.org/' => array(
|
||||
'domain' => 'wordpress.org',
|
||||
'path' => '/',
|
||||
'site_id' => self::$network_ids['wordpress.org/'],
|
||||
'domain' => 'wordpress.org',
|
||||
'path' => '/',
|
||||
'network_id' => self::$network_ids['wordpress.org/'],
|
||||
),
|
||||
'wordpress.org/foo/' => array(
|
||||
'domain' => 'wordpress.org',
|
||||
'path' => '/foo/',
|
||||
'site_id' => self::$network_ids['wordpress.org/'],
|
||||
'domain' => 'wordpress.org',
|
||||
'path' => '/foo/',
|
||||
'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/'],
|
||||
'domain' => 'wordpress.org',
|
||||
'path' => '/foo/bar/',
|
||||
'network_id' => self::$network_ids['wordpress.org/'],
|
||||
),
|
||||
'make.wordpress.org/' => array(
|
||||
'domain' => 'make.wordpress.org',
|
||||
'path' => '/',
|
||||
'site_id' => self::$network_ids['make.wordpress.org/'],
|
||||
'domain' => 'make.wordpress.org',
|
||||
'path' => '/',
|
||||
'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/'],
|
||||
'domain' => 'make.wordpress.org',
|
||||
'path' => '/foo/',
|
||||
'network_id' => self::$network_ids['make.wordpress.org/'],
|
||||
),
|
||||
'www.w.org/' => array(
|
||||
'domain' => 'www.w.org',
|
||||
@ -86,12 +86,10 @@ if ( is_multisite() ) :
|
||||
'path' => '/foo/bar/',
|
||||
),
|
||||
'www.w.org/make/' => array(
|
||||
'domain' => 'www.w.org',
|
||||
'path' => '/make/',
|
||||
'meta' => array(
|
||||
'public' => 1,
|
||||
'lang_id' => 1,
|
||||
),
|
||||
'domain' => 'www.w.org',
|
||||
'path' => '/make/',
|
||||
'public' => 1,
|
||||
'lang_id' => 1,
|
||||
),
|
||||
);
|
||||
|
||||
|
@ -13,21 +13,21 @@ if ( is_multisite() ) :
|
||||
public static function wpSetUpBeforeClass( $factory ) {
|
||||
self::$site_ids = array(
|
||||
'w.org/' => array(
|
||||
'domain' => 'w.org',
|
||||
'path' => '/',
|
||||
'site_id' => 2,
|
||||
'domain' => 'w.org',
|
||||
'path' => '/',
|
||||
'network_id' => 2,
|
||||
),
|
||||
'wp.org/' => array(
|
||||
'domain' => 'wp.org',
|
||||
'path' => '/',
|
||||
'site_id' => 2,
|
||||
'meta' => array( 'public' => 0 ),
|
||||
'domain' => 'wp.org',
|
||||
'path' => '/',
|
||||
'network_id' => 2,
|
||||
'public' => 0,
|
||||
),
|
||||
'wp.org/foo/' => array(
|
||||
'domain' => 'wp.org',
|
||||
'path' => '/foo/',
|
||||
'site_id' => 1,
|
||||
'meta' => array( 'public' => 0 ),
|
||||
'domain' => 'wp.org',
|
||||
'path' => '/foo/',
|
||||
'network_id' => 1,
|
||||
'public' => 0,
|
||||
),
|
||||
'wp.org/oof/' => array(
|
||||
'domain' => 'wp.org',
|
||||
|
@ -34,9 +34,9 @@ if ( is_multisite() ) :
|
||||
|
||||
self::$existing_blog_id = $factory->blog->create(
|
||||
array(
|
||||
'domain' => $domain,
|
||||
'path' => $path,
|
||||
'site_id' => $network->id,
|
||||
'domain' => $domain,
|
||||
'path' => $path,
|
||||
'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,
|
||||
),
|
||||
'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 ) );
|
||||
}
|
||||
$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,34 +154,33 @@ 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 ) {
|
||||
$this->assertInternalType( 'int', $blog_id );
|
||||
$blog_id = self::factory()->blog->create( array( 'user_id' => get_current_user_id() ) );
|
||||
|
||||
// Current user gets added to new blogs
|
||||
$this->assertTrue( is_user_member_of_blog( $user1_id, $blog_id ) );
|
||||
// Other users should not
|
||||
$this->assertFalse( is_user_member_of_blog( $user2_id, $blog_id ) );
|
||||
$this->assertInternalType( 'int', $blog_id );
|
||||
|
||||
switch_to_blog( $blog_id );
|
||||
// Current user gets added to new blogs
|
||||
$this->assertTrue( is_user_member_of_blog( $user1_id, $blog_id ) );
|
||||
// Other users should not
|
||||
$this->assertFalse( is_user_member_of_blog( $user2_id, $blog_id ) );
|
||||
|
||||
$this->assertTrue( is_user_member_of_blog( $user1_id ) );
|
||||
$this->assertFalse( is_user_member_of_blog( $user2_id ) );
|
||||
switch_to_blog( $blog_id );
|
||||
|
||||
// Remove user 1 from blog
|
||||
$this->assertTrue( remove_user_from_blog( $user1_id, $blog_id ) );
|
||||
$this->assertTrue( is_user_member_of_blog( $user1_id ) );
|
||||
$this->assertFalse( is_user_member_of_blog( $user2_id ) );
|
||||
|
||||
// Add user 2 to blog
|
||||
$this->assertTrue( add_user_to_blog( $blog_id, $user2_id, 'subscriber' ) );
|
||||
// Remove user 1 from blog
|
||||
$this->assertTrue( remove_user_from_blog( $user1_id, $blog_id ) );
|
||||
|
||||
$this->assertFalse( is_user_member_of_blog( $user1_id ) );
|
||||
$this->assertTrue( is_user_member_of_blog( $user2_id ) );
|
||||
// Add user 2 to blog
|
||||
$this->assertTrue( add_user_to_blog( $blog_id, $user2_id, 'subscriber' ) );
|
||||
|
||||
restore_current_blog();
|
||||
$this->assertFalse( is_user_member_of_blog( $user1_id ) );
|
||||
$this->assertTrue( is_user_member_of_blog( $user2_id ) );
|
||||
|
||||
$this->assertFalse( is_user_member_of_blog( $user1_id, $blog_id ) );
|
||||
$this->assertTrue( is_user_member_of_blog( $user2_id, $blog_id ) );
|
||||
}
|
||||
restore_current_blog();
|
||||
|
||||
$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