| 651 | /** |
| 652 | * @group bp_blogs_record_comment |
| 653 | */ |
| 654 | public function test_bp_blogs_record_comment_no_duplicate_activity_comments() { |
| 655 | // save the current user and override logged-in user |
| 656 | $old_user = get_current_user_id(); |
| 657 | $u = $this->factory->user->create(); |
| 658 | $this->set_current_user( $u ); |
| 659 | $userdata = get_userdata( $u ); |
| 660 | |
| 661 | // let's use activity comments instead of single "new_blog_comment" activity items |
| 662 | add_filter( 'bp_disable_blogforum_comments', '__return_false' ); |
| 663 | |
| 664 | // create the blog post |
| 665 | $post_id = $this->factory->post->create( array( |
| 666 | 'post_status' => 'publish', |
| 667 | 'post_type' => 'post', |
| 668 | 'post_title' => 'Test Duplicate activity comments', |
| 669 | ) ); |
| 670 | |
| 671 | // grab the activity ID for the activity comment |
| 672 | $a1 = bp_activity_get_activity_id( array( |
| 673 | 'type' => 'new_blog_post', |
| 674 | 'component' => buddypress()->blogs->id, |
| 675 | 'filter' => array( |
| 676 | 'item_id' => get_current_blog_id(), |
| 677 | 'secondary_item_id' => $post_id |
| 678 | ), |
| 679 | ) ); |
| 680 | |
| 681 | $a2 = bp_activity_new_comment( array( |
| 682 | 'content' => 'activity comment should be unique', |
| 683 | 'user_id' => $u, |
| 684 | 'activity_id' => $a1, |
| 685 | ) ); |
| 686 | |
| 687 | $activities = bp_activity_get( array( |
| 688 | 'type' => 'activity_comment', |
| 689 | 'display_comments' => 'stream', |
| 690 | 'search_terms' => 'activity comment should be unique', |
| 691 | ) ); |
| 692 | |
| 693 | $this->assertTrue( count( $activities['activities'] ) === 1, 'An activity comment should be unique' ); |
| 694 | |
| 695 | // reset |
| 696 | remove_filter( 'bp_disable_blogforum_comments', '__return_false' ); |
| 697 | $this->set_current_user( $old_user ); |
| 698 | } |
| 699 | |