Changeset 8332 for trunk/tests/testcases/core/class-bp-core-user.php
- Timestamp:
- 04/30/2014 05:22:22 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/testcases/core/class-bp-core-user.php
r8326 r8332 159 159 /** 160 160 * @group last_activity 161 * @group cache 161 162 */ 162 163 public function test_get_last_activity_store_in_cache() { … … 176 177 /** 177 178 * @group last_activity 178 */ 179 public function test_get_last_activity_in_cache_single_user() { 179 * @group cache 180 */ 181 public function test_get_last_activity_store_in_cache_multiple_users() { 182 $u1 = $this->create_user(); 183 $u2 = $this->create_user(); 184 $time = bp_core_current_time(); 185 186 // Cache is set during user creation. Clear to reflect actual 187 // pageload 188 wp_cache_delete( $u1, 'bp_last_activity' ); 189 wp_cache_delete( $u2, 'bp_last_activity' ); 190 191 // prime cache 192 $a = BP_Core_User::get_last_activity( array( $u1, $u2 ) ); 193 194 $this->assertSame( $a[ $u1 ], wp_cache_get( $u1, 'bp_last_activity' ) ); 195 $this->assertSame( $a[ $u2 ], wp_cache_get( $u2, 'bp_last_activity' ) ); 196 } 197 198 /** 199 * @group last_activity 200 * @group cache 201 */ 202 public function test_get_last_activity_from_cache_single_user() { 180 203 $u = $this->create_user(); 181 204 $time = bp_core_current_time(); … … 183 206 BP_Core_User::update_last_activity( $u, $time ); 184 207 208 // Cache is set during user creation. Clear to reflect actual 209 // pageload 210 wp_cache_delete( $u, 'bp_last_activity' ); 211 212 // Prime cache 213 $uncached = BP_Core_User::get_last_activity( $u ); 214 215 // Fetch again to get from the cache 216 $cached = BP_Core_User::get_last_activity( $u ); 217 218 $this->assertSame( $uncached, $cached ); 219 } 220 221 /** 222 * @group last_activity 223 * @group cache 224 */ 225 public function test_get_last_activity_in_cache_multiple_users() { 226 $u1 = $this->create_user(); 227 $u2 = $this->create_user(); 228 $time = bp_core_current_time(); 229 230 BP_Core_User::update_last_activity( $u1, $time ); 231 BP_Core_User::update_last_activity( $u2, $time ); 232 185 233 // Cache is set during user creation. Clear to reflect actual pageload 186 wp_cache_delete( $u, 'bp_last_activity' ); 187 188 // prime cache 189 $a = BP_Core_User::get_last_activity( $u ); 190 $b = BP_Core_User::get_last_activity( $u ); 191 192 $this->assertSame( $a, $b ); 234 wp_cache_delete( $u1, 'bp_last_activity' ); 235 wp_cache_delete( $u2, 'bp_last_activity' ); 236 237 // Prime cache 238 $uncached = BP_Core_User::get_last_activity( array( $u1, $u2 ) ); 239 240 // Second grab will be from the cache 241 $cached = BP_Core_User::get_last_activity( array( $u1, $u2 ) ); 242 $cached_u1 = wp_cache_get( $u1, 'bp_last_activity' ); 243 244 $this->assertSame( $cached, $uncached ); 193 245 } 194 246
Note: See TracChangeset
for help on using the changeset viewer.