Changeset 11865 for trunk/tests/phpunit/testcases/friends/functions.php
- Timestamp:
- 02/27/2018 01:29:33 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/testcases/friends/functions.php
r11737 r11865 283 283 * @group friendship_caching 284 284 */ 285 public function test_friends_check_friendship_should_hit_user_cache() {286 global $wpdb;287 $now = time();288 $u1 = self::factory()->user->create( array(289 'last_activity' => date( 'Y-m-d H:i:s', $now ),290 ) );291 $u2 = self::factory()->user->create( array(292 'last_activity' => date( 'Y-m-d H:i:s', $now - 100 ),293 ) );294 $u3 = self::factory()->user->create( array(295 'last_activity' => date( 'Y-m-d H:i:s', $now - 200 ),296 ) );297 298 friends_add_friend( $u1, $u2, true );299 friends_add_friend( $u1, $u3, false );300 301 friends_check_friendship_status( $u1, $u2 );302 $first_query_count = $wpdb->num_queries;303 304 friends_check_friendship_status( $u1, $u3 );305 306 $this->assertEquals( $first_query_count, $wpdb->num_queries );307 }308 309 /**310 * @group friendship_caching311 */312 285 public function test_friends_check_friendship_should_hit_friendship_object_cache() { 313 286 global $wpdb; … … 326 299 327 300 /* 328 * We expect this to generate one query to find $u2's friendships, 329 * but the friendship object itself should come from cache. 301 * This should access the previous friendship check's cached items. 330 302 */ 331 303 friends_check_friendship_status( $u2, $u1 ); 332 304 333 $this->assertEquals( $first_query_count + 1, $wpdb->num_queries );305 $this->assertEquals( $first_query_count, $wpdb->num_queries ); 334 306 } 335 307
Note: See TracChangeset
for help on using the changeset viewer.