| | 528 | * @group scope |
| | 529 | */ |
| | 530 | function test_bp_has_activities_scope_friends_shoud_respect_id_order_when_record_dates_are_same() { |
| | 531 | $u1 = $this->factory->user->create(); |
| | 532 | $u2 = $this->factory->user->create(); |
| | 533 | |
| | 534 | friends_add_friend( $u1, $u2, true ); |
| | 535 | |
| | 536 | // Friend's very fast status updates. |
| | 537 | $a1 = $this->factory->activity->create( array( |
| | 538 | 'user_id' => $u2, |
| | 539 | 'type' => 'activity_update', |
| | 540 | 'recorded_time' => date( 'Y-m-d H:i:s', 1451944920 ), |
| | 541 | ) ); |
| | 542 | $a2 = $this->factory->activity->create( array( |
| | 543 | 'user_id' => $u2, |
| | 544 | 'type' => 'activity_update', |
| | 545 | 'recorded_time' => date( 'Y-m-d H:i:s', 1451944920 ), |
| | 546 | ) ); |
| | 547 | |
| | 548 | global $activities_template; |
| | 549 | $reset_activities_template = $activities_template; |
| | 550 | |
| | 551 | // Get activities in 'friends' scope |
| | 552 | bp_has_activities( array( |
| | 553 | 'user_id' => $u1, |
| | 554 | 'scope' => 'friends', |
| | 555 | ) ); |
| | 556 | |
| | 557 | $this->assertEquals( array( $a2, $a1 ), wp_list_pluck( $activities_template->activities, 'id' ) ); |
| | 558 | |
| | 559 | // Clean up! |
| | 560 | $activities_template = $reset_activities_template; |
| | 561 | } |
| | 562 | |
| | 563 | /** |
| | 564 | * @group scope |
| | 565 | */ |
| | 566 | function test_bp_has_activities_scope_groups_shoud_respect_id_order_when_record_dates_are_same() { |
| | 567 | $u1 = $this->factory->user->create(); |
| | 568 | $u2 = $this->factory->user->create(); |
| | 569 | $u3 = $this->factory->user->create(); |
| | 570 | |
| | 571 | $g1 = $this->factory->group->create( array( 'creator_id' => $u1 ) ); |
| | 572 | |
| | 573 | // Two user join first user's group same time |
| | 574 | $a1 = $this->factory->activity->create( array( |
| | 575 | 'user_id' => $u2, |
| | 576 | 'component' => 'groups', |
| | 577 | 'item_id' => $g1, |
| | 578 | 'type' => 'joined_group', |
| | 579 | 'recorded_time' => date( 'Y-m-d H:i:s', 1451944920 ), |
| | 580 | ) ); |
| | 581 | $a2 = $this->factory->activity->create( array( |
| | 582 | 'user_id' => $u3, |
| | 583 | 'component' => 'groups', |
| | 584 | 'item_id' => $g1, |
| | 585 | 'type' => 'joined_group', |
| | 586 | 'recorded_time' => date( 'Y-m-d H:i:s', 1451944920 ), |
| | 587 | ) ); |
| | 588 | |
| | 589 | |
| | 590 | global $activities_template; |
| | 591 | $reset_activities_template = $activities_template; |
| | 592 | |
| | 593 | // Get activities in 'groups' scope |
| | 594 | bp_has_activities( array( |
| | 595 | 'user_id' => $u1, |
| | 596 | 'scope' => 'groups', |
| | 597 | ) ); |
| | 598 | |
| | 599 | $this->assertEquals( array( $a2, $a1 ), wp_list_pluck( $activities_template->activities, 'id' ) ); |
| | 600 | |
| | 601 | // Clean up! |
| | 602 | $activities_template = $reset_activities_template; |
| | 603 | } |
| | 604 | |
| | 605 | /** |