| | 209 | * @ticket 37866 |
| | 210 | */ |
| | 211 | public function test_get_user_count_on_different_network() { |
| | 212 | global $current_site, $wpdb; |
| | 213 | |
| | 214 | wp_update_network_user_counts(); |
| | 215 | $current_network_user_count = get_user_count(); |
| | 216 | |
| | 217 | // switch_to_network()... |
| | 218 | $orig_network_id = $current_site->id; |
| | 219 | $orig_wpdb_network_id = $wpdb->siteid; |
| | 220 | $current_site->id = self::$different_network_id; |
| | 221 | $wpdb->siteid = self::$different_network_id; |
| | 222 | |
| | 223 | // Add another user to fake the network user count to be different. |
| | 224 | wpmu_create_user( 'user', 'pass', 'email' ); |
| | 225 | |
| | 226 | wp_update_network_user_counts(); |
| | 227 | |
| | 228 | // restore_current_network()... |
| | 229 | $current_site->id = $orig_network_id; |
| | 230 | $wpdb->siteid = $orig_wpdb_network_id; |
| | 231 | |
| | 232 | $user_count = get_user_count( self::$different_network_id ); |
| | 233 | |
| | 234 | $this->assertEquals( $current_network_user_count + 1, $user_count ); |
| | 235 | } |
| | 236 | |
| | 237 | /** |