Changeset 42343 for trunk/tests/phpunit/tests/multisite/getSite.php
- Timestamp:
- 11/30/2017 11:09:33 PM (8 years ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/multisite/getSite.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/multisite/getSite.php
r38217 r42343 2 2 3 3 if ( is_multisite() ) : 4 /**5 * Test get_site() wrapper of WP_Site in multisite.6 *7 * @group ms-site8 * @group multisite9 */10 class Tests_Multisite_Get_Site extends WP_UnitTestCase {11 protected static $site_ids;4 /** 5 * Test get_site() wrapper of WP_Site in multisite. 6 * 7 * @group ms-site 8 * @group multisite 9 */ 10 class Tests_Multisite_Get_Site extends WP_UnitTestCase { 11 protected static $site_ids; 12 12 13 public static function wpSetUpBeforeClass( $factory ) { 14 self::$site_ids = array( 15 'wordpress.org/' => array( 'domain' => 'wordpress.org', 'path' => '/' ), 16 'wordpress.org/foo/' => array( 'domain' => 'wordpress.org', 'path' => '/foo/' ), 17 'wordpress.org/foo/bar/' => array( 'domain' => 'wordpress.org', 'path' => '/foo/bar/' ), 18 ); 13 public static function wpSetUpBeforeClass( $factory ) { 14 self::$site_ids = array( 15 'wordpress.org/' => array( 16 'domain' => 'wordpress.org', 17 'path' => '/', 18 ), 19 'wordpress.org/foo/' => array( 20 'domain' => 'wordpress.org', 21 'path' => '/foo/', 22 ), 23 'wordpress.org/foo/bar/' => array( 24 'domain' => 'wordpress.org', 25 'path' => '/foo/bar/', 26 ), 27 ); 19 28 20 foreach ( self::$site_ids as &$id ) { 21 $id = $factory->blog->create( $id ); 29 foreach ( self::$site_ids as &$id ) { 30 $id = $factory->blog->create( $id ); 31 } 32 unset( $id ); 22 33 } 23 unset( $id ); 34 35 public static function wpTearDownAfterClass() { 36 foreach ( self::$site_ids as $id ) { 37 wpmu_delete_blog( $id, true ); 38 } 39 40 wp_update_network_site_counts(); 41 } 42 43 public function test_get_site_in_switched_state_returns_switched_site() { 44 switch_to_blog( self::$site_ids['wordpress.org/foo/'] ); 45 $site = get_site(); 46 restore_current_blog(); 47 48 $this->assertEquals( self::$site_ids['wordpress.org/foo/'], $site->id ); 49 } 50 24 51 } 25 52 26 public static function wpTearDownAfterClass() {27 foreach( self::$site_ids as $id ) {28 wpmu_delete_blog( $id, true );29 }30 31 wp_update_network_site_counts();32 }33 34 public function test_get_site_in_switched_state_returns_switched_site() {35 switch_to_blog( self::$site_ids[ 'wordpress.org/foo/' ] );36 $site = get_site();37 restore_current_blog();38 39 $this->assertEquals( self::$site_ids[ 'wordpress.org/foo/'], $site->id );40 }41 42 }43 44 53 endif;
Note: See TracChangeset
for help on using the changeset viewer.