WordPress.org

Make WordPress Core

Changeset 458 in tests


Ignore:
Timestamp:
10/19/2011 10:34:14 PM (7 years ago)
Author:
ryan
Message:

is_user_member_of_blog() tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wp-testcase/test_ms.php

    r457 r458  
    139139    }
    140140
     141    function is_user_member_of_blog() {
     142        global $current_site, $wpdb;
     143
     144        $user1_id = $this->_make_user('administrator');
     145
     146        $old_current = get_current_user_id();
     147        set_current_user( $user1_id );
     148
     149        $this->assertTrue( is_user_member_of_blog() );
     150        $this->assertTrue( is_user_member_of_blog( 0, 0 ) );
     151        $this->assertTrue( is_user_member_of_blog( 0, $wpdb->blogid ) );
     152        $this->assertTrue( is_user_member_of_blog( $user1_id ) );
     153        $this->assertTrue( is_user_member_of_blog( $user1_id, $wpdb->blogid ) );
     154
     155        $blog_ids = array();
     156
     157        for ( $i=1; $i <= 5; $i++ ) {
     158            $blog_id = wpmu_create_blog( $current_site->domain, 'testpath'.$i, "testTitle".$i, $user1_id );
     159            $this->assertInternalType( 'int', $blog_id );
     160            $blog_ids[] = $blog_id;
     161            $this->assertTrue( is_user_member_of_blog( $user1_id, $blog_id ) );
     162        }
     163
     164        foreach ( $blog_ids as $blog_id ) {
     165            $this->assertTrue( remove_user_from_blog( $user1_id, $blog_id ) );
     166            $this->assertFalse( is_user_member_of_blog( $user1_id, $blog_id ) );
     167        }
     168
     169        set_current_user( $old_current );
     170
     171        foreach ( $blog_ids as $blog_id )
     172            wpmu_delete_blog( $blog_id );
     173    }
     174
    141175    function test_active_network_plugins() {
    142176        $path = "hello.php";
Note: See TracChangeset for help on using the changeset viewer.