Changeset 40370 for trunk/tests/phpunit/tests/multisite/network.php
- Timestamp:
- 04/03/2017 11:13:40 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/multisite/network.php
r37870 r40370 13 13 protected $suppress = false; 14 14 15 protected static $different_network_id; 16 protected static $different_site_ids = array(); 17 15 18 function setUp() { 16 19 global $wpdb; … … 26 29 } 27 30 31 public static function wpSetUpBeforeClass( $factory ) { 32 self::$different_network_id = $factory->network->create( array( 'domain' => 'wordpress.org', 'path' => '/' ) ); 33 34 $sites = array( 35 array( 'domain' => 'wordpress.org', 'path' => '/', 'site_id' => self::$different_network_id ), 36 array( 'domain' => 'wordpress.org', 'path' => '/foo/', 'site_id' => self::$different_network_id ), 37 array( 'domain' => 'wordpress.org', 'path' => '/bar/', 'site_id' => self::$different_network_id ), 38 ); 39 40 foreach ( $sites as $site ) { 41 self::$different_site_ids[] = $factory->blog->create( $site ); 42 } 43 } 44 45 public static function wpTearDownAfterClass() { 46 global $wpdb; 47 48 foreach( self::$different_site_ids as $id ) { 49 wpmu_delete_blog( $id, true ); 50 } 51 52 $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->sitemeta} WHERE site_id = %d", self::$different_network_id ) ); 53 $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->site} WHERE id= %d", self::$different_network_id ) ); 54 55 wp_update_network_site_counts(); 56 } 57 28 58 /** 29 59 * By default, only one network exists and has a network ID of 1. … … 67 97 global $wpdb, $current_site; 68 98 69 $id = self::factory()->network->create(); 70 $temp_id = $id + 1; 71 72 $current_site->id = (int) $id; 99 $temp_id = self::$different_network_id + 1; 100 101 $current_site->id = (int) self::$different_network_id; 73 102 $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->site} SET id=%d WHERE id=1", $temp_id ) ); 74 103 $main_network_id = get_main_network_id(); 75 104 $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->site} SET id=1 WHERE id=%d", $temp_id ) ); 76 105 77 $this->assertEquals( $id, $main_network_id );106 $this->assertEquals( self::$different_network_id, $main_network_id ); 78 107 } 79 108 … … 158 187 159 188 /** 189 * @ticket 37865 190 */ 191 public function test_get_blog_count_on_different_network() { 192 global $current_site, $wpdb; 193 194 // switch_to_network()... 195 $orig_network_id = $current_site->id; 196 $orig_wpdb_network_id = $wpdb->siteid; 197 $current_site->id = self::$different_network_id; 198 $wpdb->siteid = self::$different_network_id; 199 wp_update_network_site_counts(); 200 $current_site->id = $orig_network_id; 201 $wpdb->siteid = $orig_wpdb_network_id; 202 203 $site_count = get_blog_count( self::$different_network_id ); 204 205 $this->assertSame( count( self::$different_site_ids ), $site_count ); 206 } 207 208 /** 160 209 * @ticket 22917 161 210 */
Note: See TracChangeset
for help on using the changeset viewer.