Changeset 9714
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-messages/classes/class-bp_messages-thread.php
r9486 r9714 509 509 $wpdb->query($sql); 510 510 511 wp_cache_delete( 'thread_recipients_' . $thread_id, 'bp_messages' ); 511 512 wp_cache_delete( bp_loggedin_user_id(), 'bp_messages_unread_count' ); 512 513 } … … 526 527 $wpdb->query($sql); 527 528 529 wp_cache_delete( 'thread_recipients_' . $thread_id, 'bp_messages' ); 528 530 wp_cache_delete( bp_loggedin_user_id(), 'bp_messages_unread_count' ); 529 531 } -
trunk/tests/phpunit/testcases/messages/class.bp-messages-thread.php
r9482 r9714 217 217 $this->assertFalse( wp_cache_get( 'thread_recipients_' . $t1, 'bp_messages' ) ); 218 218 } 219 220 /** 221 * @group get_recipients 222 * @group cache 223 */ 224 public function test_get_recipients_cache_should_be_busted_when_thread_is_read() { 225 global $wpdb; 226 227 $u1 = $this->factory->user->create(); 228 $u2 = $this->factory->user->create(); 229 230 $t1 = $this->factory->message->create( array( 231 'sender_id' => $u1, 232 'recipients' => array( $u2 ), 233 'subject' => 'Foo', 234 ) ); 235 236 $thread = new BP_Messages_Thread( $t1 ); 237 $recipients = $thread->get_recipients(); 238 239 // Verify that the cache is populated. 240 $num_queries = $wpdb->num_queries; 241 $recipients_cached = $thread->get_recipients(); 242 $this->assertEquals( $num_queries, $wpdb->num_queries ); 243 244 // Mark thread as read 245 $current_user = get_current_user_id(); 246 $this->set_current_user( $u2 ); 247 messages_mark_thread_read( $t1 ); 248 249 // Cache should be empty. 250 $this->assertFalse( wp_cache_get( 'thread_recipients_' . $t1, 'bp_messages' ) ); 251 252 $this->set_current_user( $current_user ); 253 } 254 255 /** 256 * @group get_recipients 257 * @group cache 258 */ 259 public function test_get_recipients_cache_should_be_busted_when_thread_is_unread() { 260 global $wpdb; 261 262 $u1 = $this->factory->user->create(); 263 $u2 = $this->factory->user->create(); 264 265 $t1 = $this->factory->message->create( array( 266 'sender_id' => $u1, 267 'recipients' => array( $u2 ), 268 'subject' => 'Foo', 269 ) ); 270 271 $thread = new BP_Messages_Thread( $t1 ); 272 $recipients = $thread->get_recipients(); 273 274 // Verify that the cache is populated. 275 $num_queries = $wpdb->num_queries; 276 $recipients_cached = $thread->get_recipients(); 277 $this->assertEquals( $num_queries, $wpdb->num_queries ); 278 279 // Mark thread as unread 280 $current_user = get_current_user_id(); 281 $this->set_current_user( $u2 ); 282 messages_mark_thread_unread( $t1 ); 283 284 // Cache should be empty. 285 $this->assertFalse( wp_cache_get( 'thread_recipients_' . $t1, 'bp_messages' ) ); 286 287 $this->set_current_user( $current_user ); 288 } 219 289 }
Note: See TracChangeset
for help on using the changeset viewer.