Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
04/26/2013 05:46:44 PM (14 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/template.php

    r6926 r6948  
    111111                $activities_template = null;
    112112        }
     113
     114        /**
     115         * Integration test for 'meta_query' param
     116         */
     117        function test_bp_has_activities_with_meta_query() {
     118                $a1 = $this->factory->activity->create();
     119                $a2 = $this->factory->activity->create();
     120                bp_activity_update_meta( $a1->id, 'foo', 'bar' );
     121
     122                global $activities_template;
     123                bp_has_activities( array(
     124                        'meta_query' => array(
     125                                array(
     126                                        'key' => 'foo',
     127                                        'value' => 'bar',
     128                                ),
     129                        ),
     130                ) );
     131
     132                $ids = wp_list_pluck( $activities_template->activities, 'id' );
     133                $this->assertEquals( $ids, array( $a1->id ) );
     134        }
    113135}
Note: See TracChangeset for help on using the changeset viewer.