Changeset 11101 for trunk/tests/phpunit/testcases/members/cache.php
- Timestamp:
- 09/14/2016 02:06:10 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/testcases/members/cache.php
r9819 r11101 23 23 $this->assertEquals( $num_queries, $wpdb->num_queries ); 24 24 } 25 26 /** 27 * @ticket BP7237 28 * @ticket BP6643 29 * @ticket BP7245 30 */ 31 public function test_last_activity_should_bust_activity_with_last_activity_cache() { 32 global $wpdb; 33 34 $u1 = $this->factory->user->create(); 35 $u2 = $this->factory->user->create(); 36 37 $time_1 = date( 'Y-m-d H:i:s', time() - HOUR_IN_SECONDS ); 38 $time_2 = date( 'Y-m-d H:i:s', time() - ( HOUR_IN_SECONDS * 2 ) ); 39 bp_update_user_last_activity( $u1, $time_1 ); 40 bp_update_user_last_activity( $u2, $time_2 ); 41 42 $activity_args_a = array( 43 'filter' => array( 44 'object' => buddypress()->members->id, 45 'action' => 'last_activity', 46 ), 47 'max' => 1, 48 ); 49 50 $activity_args_b = array( 51 'filter' => array( 52 'action' => 'new_member', 53 ), 54 'fields' => 'ids', 55 ); 56 57 // Prime bp_activity and bp_activity_with_last_activity caches. 58 $a1 = bp_activity_get( $activity_args_a ); 59 $expected = array( $u1, $u2 ); 60 $found = array_map( 'intval', wp_list_pluck( $a1['activities'], 'user_id' ) ); 61 $this->assertSame( $expected, $found ); 62 63 $b1 = bp_activity_get( $activity_args_b ); 64 65 // Bump u2 activity so it should appear first. 66 $new_time = date( 'Y-m-d H:i:s', time() - HOUR_IN_SECONDS ); 67 bp_update_user_last_activity( $u2, $new_time ); 68 69 $a2 = bp_activity_get( $activity_args_a ); 70 $expected = array( $u2, $u1 ); 71 $found = array_map( 'intval', wp_list_pluck( $a2['activities'], 'user_id' ) ); 72 $this->assertSame( $expected, $found ); 73 74 $num_queries = $wpdb->num_queries; 75 76 // bp_activity cache should not have been touched. 77 $b2 = bp_activity_get( $activity_args_b ); 78 $this->assertEqualSets( $b1, $b2 ); 79 $this->assertSame( $num_queries, $wpdb->num_queries ); 80 } 25 81 } 26 82
Note: See TracChangeset
for help on using the changeset viewer.