Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
04/26/2013 05:46:44 PM (9 years ago)
Author:
boonebgorges
Message:

Introduces meta_query paramater for bp_has_activities() stack

This will allow plugin and theme authors to filter the contents of the activity
stream based on information stored in the activitymeta table, using the
powerful meta_query syntax familiar from the 'meta_query' WP_Query param.

Also adds unit test for 'meta_query' in BP_Activity_Activity::get(), and
integration test for bp_has_activities(). These tests are primarily designed
to ensure that our param gets passed properly down the stack; we rely on WP
to get the meta_query logic right.

See #3521

Props ericlewis

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/testcases/activity/class.BP_Activity_Activity.php

    r6907 r6948  
    7373        $this->assertEquals( $activity['activities'][0]->hide_sitewide, 1 );
    7474    }
     75
     76    public function test_get_meta_query() {
     77        $a1 = $this->factory->activity->create();
     78        $a2 = $this->factory->activity->create();
     79        bp_activity_update_meta( $a1->id, 'foo', 'bar' );
     80
     81        $activity = BP_Activity_Activity::get( array(
     82            'meta_query' => array(
     83                array(
     84                    'key' => 'foo',
     85                    'value' => 'bar',
     86                ),
     87            ),
     88        ) );
     89        $ids = wp_list_pluck( $activity['activities'], 'id' );
     90        $this->assertEquals( $ids, array( $a1->id ) );
     91    }
    7592}
Note: See TracChangeset for help on using the changeset viewer.