Changeset 13248
- Timestamp:
- 02/25/2022 01:45:23 PM (3 years ago)
- Location:
- branches/10.0
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/10.0/src/bp-notifications/bp-notifications-cache.php
r13244 r13248 105 105 // Get the list of user IDs from notification IDs. 106 106 } elseif ( isset( $where_args['ids'] ) && $where_args['ids'] ) { 107 $ids = (array) $where_args['ids']; 107 $ids = (array) $where_args['ids']; 108 $is_new = 1; 109 110 if ( isset( $update_args['data']['is_new'] ) && 1 === $update_args['data']['is_new'] ) { 111 $is_new = 0; 112 } 108 113 109 114 $ns = BP_Notifications_Notification::get( 110 115 array( 111 'id' => $ids, 116 'id' => $ids, 117 'is_new' => $is_new, 112 118 ) 113 119 ); -
branches/10.0/tests/phpunit/testcases/notifications/cache.php
r13244 r13248 229 229 /** 230 230 * @group cache 231 * @ticket BP8642 232 */ 233 public function test_bp_notifications_clear_all_for_user_cache_before_update_when_marked_unread() { 234 $u = self::factory()->user->create(); 235 $a = self::factory()->activity->create(); 236 237 $notification_ids = self::factory()->notification->create_many( 238 4, 239 array( 240 'component_name' => 'activity', 241 'component_action' => 'at_mentions', 242 'user_id' => $u, 243 'item_id' => $a, 244 'is_new' => 0, 245 'allow_duplicate' => true, 246 ) 247 ); 248 249 $all_for_user_notifications = bp_notifications_get_all_notifications_for_user( $u ); 250 $this->assertEmpty( $all_for_user_notifications ); 251 252 // Mark as unread. 253 $amount = bp_notifications_mark_notifications_by_ids( $notification_ids, 1 ); 254 $this->assertTrue( $amount === count( $notification_ids ) ); 255 256 $all_for_user_notifications = bp_notifications_get_all_notifications_for_user( $u ); 257 $this->assertEquals( $notification_ids, wp_list_pluck( $all_for_user_notifications, 'id' ) ); 258 } 259 260 /** 261 * @group cache 231 262 * @ticket BP8637 232 263 */ … … 317 348 /** 318 349 * @group cache 350 * @ticket BP8642 351 */ 352 public function test_bp_notifications_clear_all_for_user_cache_before_update_when_item_ids_and_marked_unread() { 353 $s = self::factory()->user->create(); 354 $r = self::factory()->user->create(); 355 $notification_ids = array(); 356 357 remove_action( 'messages_message_sent', 'bp_messages_message_sent_add_notification', 10 ); 358 359 $message_ids = self::factory()->message->create_many( 360 4, 361 array( 362 'sender_id' => $s, 363 'recipients' => array( $r ), 364 'content' => 'testing notification all for user cache', 365 ) 366 ); 367 368 foreach ( $message_ids as $message_id ) { 369 $notification_ids[] = self::factory()->notification->create( 370 array( 371 'component_name' => 'messages', 372 'component_action' => 'new_message', 373 'user_id' => $r, 374 'item_id' => $message_id, 375 'is_new' => 0, 376 ) 377 ); 378 } 379 380 add_action( 'messages_message_sent', 'bp_messages_message_sent_add_notification', 10 ); 381 382 $all_for_user_notifications = bp_notifications_get_all_notifications_for_user( $r ); 383 $this->assertEmpty( $all_for_user_notifications ); 384 385 // Mark unread. 386 $amount = bp_notifications_mark_notifications_by_item_ids( $r, $message_ids, 'messages', 'new_message', 1 ); 387 $this->assertTrue( $amount === count( $message_ids ) ); 388 389 $all_for_user_notifications = bp_notifications_get_all_notifications_for_user( $r ); 390 $this->assertEquals( $message_ids, wp_list_pluck( $all_for_user_notifications, 'item_id' ) ); 391 } 392 393 /** 394 * @group cache 319 395 * @ticket BP8637 320 396 */
Note: See TracChangeset
for help on using the changeset viewer.