1 | <?php |
---|
2 | |
---|
3 | if ( is_multisite() ) : |
---|
4 | |
---|
5 | /** |
---|
6 | * A set of unit tests for WordPress Multisite |
---|
7 | * |
---|
8 | * @group multisite |
---|
9 | */ |
---|
10 | class Tests_MS_Switch_Interference extends WP_UnitTestCase { |
---|
11 | |
---|
12 | function test_interference() { |
---|
13 | global $wpdb, $current_site; |
---|
14 | |
---|
15 | $user1_id = $this->factory->user->create( array( 'role' => 'administrator' ) ); |
---|
16 | $blog_ids = array(); |
---|
17 | $blog_ids[] = $this->factory->blog->create( array( 'title' => 'site1', 'user_id' => $user1_id ) ); |
---|
18 | $blog_ids[] = $this->factory->blog->create( array( 'title' => 'site2' ) ); |
---|
19 | $blog_ids[] = $this->factory->blog->create( array( 'title' => 'site3', 'user_id' => $user1_id ) ); |
---|
20 | wp_set_current_user( $user1_id ); |
---|
21 | |
---|
22 | $sites = array(); |
---|
23 | foreach ( $blog_ids as $blog_id ) { |
---|
24 | if( !current_user_can_for_blog( $blog_id , 'upload_files') ) continue; |
---|
25 | $sites[] = get_blog_option( $blog_id, 'blogname' ); |
---|
26 | } |
---|
27 | |
---|
28 | $this->assertEquals( array( 'site1', 'site3' ), $sites ); |
---|
29 | |
---|
30 | // cleanup |
---|
31 | foreach ( $blog_ids as $blog_id ) { |
---|
32 | wpmu_delete_blog( $blog_id, true ); |
---|
33 | } |
---|
34 | } |
---|
35 | } |
---|
36 | endif; |
---|