Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
08/01/2014 07:58:47 PM (9 years ago)
Author:
boonebgorges
Message:

Ensure that the 'Comments' dropdown filter on the activity directory includes new- and old-style comment activity

The change in BuddyPress 2.0 to storing blog comment activity in
activity_comment items resulted in the 'Comments' dropdown filter breaking: it
continued to return only 'new_blog_comment' items. This changeset introduces
a number of filters to ensure that both the appropriate 'activity_comment'
and 'new_blog_comment' items are included when passing 'action=new_blog_comment'
to bp_has_activities().

See #5608

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/activity/template.php

    r8491 r8747  
    310310
    311311    /**
     312     * @group bp_has_activities
     313     */
     314    public function test_bp_has_activities_with_type_new_blog_comments() {
     315        add_filter( 'bp_disable_blogforum_comments', '__return_false' );
     316
     317        $now = time();
     318        $a1 = $this->factory->activity->create( array(
     319            'content' => 'Life Rules',
     320            'component' => 'blogs',
     321            'type' => 'new_blog_post',
     322            'recorded_time' => date( 'Y-m-d H:i:s', $now ),
     323        ) );
     324        $a2 = $this->factory->activity->create( array(
     325            'content' => 'Life Drools',
     326            'component' => 'blogs',
     327            'type' => 'new_blog_comment',
     328            'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ),
     329        ) );
     330
     331        // This one will show up in the stream because it's a comment
     332        // on a blog post
     333        $a3 = bp_activity_new_comment( array(
     334            'activity_id' => $a1,
     335            'content' => 'Candy is good',
     336            'recorded_time' => date( 'Y-m-d H:i:s', $now - 200 ),
     337        ) );
     338
     339        $a4 = $this->factory->activity->create( array(
     340            'content' => 'Life Rulez',
     341            'component' => 'activity',
     342            'type' => 'activity_update',
     343            'recorded_time' => date( 'Y-m-d H:i:s', $now - 300 ),
     344        ) );
     345
     346        // This one should not show up in the stream because it's a
     347        // comment on an activity item
     348        $a5 = bp_activity_new_comment( array(
     349            'activity_id' => $a4,
     350            'content' => 'Candy is great',
     351            'recorded_time' => date( 'Y-m-d H:i:s', $now - 400 ),
     352        ) );
     353        global $activities_template;
     354
     355        // prime
     356        bp_has_activities( array(
     357            'component' => 'blogs',
     358            'action' => 'new_blog_comment',
     359        ) );
     360
     361        $this->assertEquals( array( $a3, $a2 ), wp_parse_id_list( wp_list_pluck( $activities_template->activities, 'id' ) ) );
     362
     363        // Clean up
     364        $activities_template = null;
     365        remove_filter( 'bp_disable_blogforum_comments', '__return_false' );
     366    }
     367
     368    /**
    312369     * @group bp_activity_can_comment_reply
    313370     */
Note: See TracChangeset for help on using the changeset viewer.