Changeset 10910
- Timestamp:
- 06/28/2016 05:23:49 PM (8 years ago)
- Location:
- branches/2.6
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.6/src/bp-notifications/bp-notifications-functions.php
r10825 r10910 255 255 // Return an array of content strings. 256 256 } else { 257 $content = call_user_func( $bp->{$component_name}->notification_callback, $component_action_name, $component_action_items[0]->item_id, $component_action_items[0]->secondary_item_id, $action_item_count, $component_action_items[0]->id );257 $content = call_user_func( $bp->{$component_name}->notification_callback, $component_action_name, $component_action_items[0]->item_id, $component_action_items[0]->secondary_item_id, $action_item_count, 'string', $component_action_items[0]->id ); 258 258 $renderable[] = $content; 259 259 } -
branches/2.6/tests/phpunit/testcases/notifications/functions.php
r10788 r10910 349 349 $this->assertEmpty( $found2 ); 350 350 } 351 352 /** 353 * @group notification_callback 354 * @ticket BP7141 355 */ 356 public function test_notification_callback_parameter_integrity() { 357 $u = $this->factory->user->create(); 358 359 $n = $this->factory->notification->create( array( 360 'component_name' => 'activity', 361 'component_action' => 'new_at_mention', 362 'item_id' => 99, 363 'user_id' => $u, 364 ) ); 365 366 // Override activity notification callback so we can test integrity. 367 buddypress()->activity->notification_callback = array( $this, 'dummy_notification_callback' ); 368 369 // Fetch notifications with string format. 370 bp_notifications_get_notifications_for_user( $u, 'string' ); 371 372 // Assert! 373 // @todo When we cast all numeric strings as integers, this needs to be changed. 374 $expected = array( 375 'action' => 'new_at_mention', 376 'item_id' => '99', 377 'secondary_item_id' => '0', 378 'total_items' => 1, 379 'id' => (string) $n, 380 'format' => 'string' 381 ); 382 $this->assertEquals( $expected, $this->n_args ); 383 384 // Fetch notifications with object format this time. 385 bp_notifications_get_notifications_for_user( $u, 'object' ); 386 387 // Assert! 388 $expected['format'] = 'array'; 389 $this->assertEquals( $expected, $this->n_args ); 390 391 // Reset! 392 buddypress()->activity->notification_callback = 'bp_activity_format_notifications'; 393 unset( $this->n_args ); 394 } 395 396 /** 397 * Used in test_notification_callback_parameter_integrity() test. 398 */ 399 public function dummy_notification_callback( $action, $item_id, $secondary_item_id, $total_items, $format = 'string', $id = 0 ) { 400 $this->n_args = compact( 'action', 'item_id', 'secondary_item_id', 'total_items', 'id', 'format' ); 401 } 351 402 }
Note: See TracChangeset
for help on using the changeset viewer.