Make WordPress Core

Changeset 30152


Ignore:
Timestamp:
11/01/2014 05:17:17 AM (10 years ago)
Author:
jeremyfelt
Message:

Split tests for is_main_site()

Break multiple assertions from one method into multiple methods with one assertion each.

See #30080

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/multisite/site.php

    r30151 r30152  
    874874    }
    875875
     876    /**
     877     * Test with default parameter of site_id as null.
     878     */
    876879    function test_is_main_site() {
    877880        $this->assertTrue( is_main_site() );
     881    }
     882
     883    /**
     884     * Test with a site id of get_current_blog_id(), which should be the same as the
     885     * default parameter tested above.
     886     */
     887    function test_current_blog_id_is_main_site() {
    878888        $this->assertTrue( is_main_site( get_current_blog_id() ) );
    879 
    880         $user_id = $this->factory->user->create( array( 'role' => 'administrator' ) );
    881         $blog_id = $this->factory->blog->create( array( 'user_id' => $user_id ) );
    882 
    883         switch_to_blog( $blog_id  );
     889    }
     890
     891    /**
     892     * Test with a site ID other than the main site to ensure a false response.
     893     */
     894    function test_is_main_site_is_false_with_other_blog_id() {
     895        $blog_id = $this->factory->blog->create();
     896
    884897        $this->assertFalse( is_main_site( $blog_id ) );
    885         $this->assertFalse( is_main_site( get_current_blog_id() ) );
     898    }
     899
     900    /**
     901     * Test with no passed ID after switching to another site ID.
     902     */
     903    function test_is_main_site_is_false_after_switch_to_blog() {
     904        $blog_id = $this->factory->blog->create();
     905        switch_to_blog( $blog_id );
     906
    886907        $this->assertFalse( is_main_site() );
    887908
Note: See TracChangeset for help on using the changeset viewer.