Changeset 41613 for trunk/tests/phpunit/tests/functions.php
- Timestamp:
- 09/27/2017 01:03:03 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/functions.php
r41388 r41613 1161 1161 return $data; 1162 1162 } 1163 1164 /** 1165 * @ticket 38741 1166 */ 1167 public function test_wp_get_active_user_count() { 1168 $user_count = wp_get_active_user_count(); 1169 $this->assertSame( $user_count, 1 ); 1170 1171 // make twenty additional users to make 21 users 1172 self::factory()->user->create_many( 20 ); 1173 1174 $user_count = wp_get_active_user_count(); 1175 $this->assertSame( $user_count, 21 ); 1176 } 1177 1178 /** 1179 * @ticket 38741 1180 */ 1181 public function test_wp_get_active_user_count_caching() { 1182 global $wpdb; 1183 1184 // Ensure we start with 1 user 1185 $user_count = wp_get_active_user_count(); 1186 $this->assertSame( $user_count, 1 ); 1187 1188 self::factory()->user->create(); 1189 1190 delete_option( 'active_user_count' ); 1191 1192 // Ensure we now have 2 users 1193 $user_count = wp_get_active_user_count(); 1194 $this->assertSame( $user_count, 2 ); 1195 1196 $queries = $wpdb->num_queries; 1197 1198 // Ensure that caching inside wp_get_active_user_count() works as expected 1199 $user_count = wp_get_active_user_count(); 1200 $this->assertSame( $user_count, 2 ); 1201 $this->assertSame( $queries, $wpdb->num_queries ); 1202 } 1203 1204 /** 1205 * @ticket 38741 1206 */ 1207 public function test_wp_is_large_user_count() { 1208 // set the 'active_user_count' value to over 10000 to emulate a large site 1209 update_option( 'active_user_count', 10001 ); 1210 $user_count = wp_get_active_user_count(); 1211 $this->assertSame( $user_count, 10001 ); 1212 $this->assertTrue( wp_is_large_user_count() ); 1213 1214 delete_option( 'active_user_count' ); 1215 $this->assertFalse( wp_is_large_user_count() ); 1216 } 1163 1217 }
Note: See TracChangeset
for help on using the changeset viewer.