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