WordPress.org

Make WordPress Core

Ticket #21459: 21459-is_main_site-ut.diff

File 21459-is_main_site-ut.diff, 873 bytes (added by ryan, 6 years ago)
  • tests/ms.php

     
    556556                $this->assertEquals( false, wp_cache_get( $key, 'blog-id-cache' ) );
    557557                $this->assertEquals( 0, get_blog_id_from_url( $details->domain, $details->path ) );
    558558        }
     559
     560        function test_is_main_site() {
     561                $this->assertTrue( is_main_site() );
     562                $this->assertTrue( is_main_site( get_current_blog_id() ) );
     563
     564                $user_id = $this->factory->user->create( array( 'role' => 'administrator' ) );
     565                $blog_id = $this->factory->blog->create( array( 'user_id' => $user_id ) );
     566
     567                switch_to_blog( $blog_id  );
     568                $this->assertFalse( is_main_site( $blog_id ) );
     569                $this->assertFalse( is_main_site( get_current_blog_id() ) );
     570                $this->assertFalse( is_main_site() );
     571
     572                restore_current_blog();
     573        }
    559574}
    560575
    561576endif;