Skip to:
Content

BuddyPress.org

Changeset 9475


Ignore:
Timestamp:
02/11/2015 09:37:30 PM (10 years ago)
Author:
r-a-y
Message:

Activity: In the 'just-me' scope, use the correct user ID variable.

Boo Ray for not catching this for v2.2.0.

See #6215 (trunk)

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-activity/bp-activity-filters.php

    r9406 r9475  
    675675        array(
    676676            'column' => 'user_id',
    677             'value'  => $filter['user_id']
     677            'value'  => $user_id
    678678        ),
    679679        $show_hidden,
  • trunk/tests/phpunit/testcases/activity/template.php

    r9471 r9475  
    140140
    141141        $activities_template = null;
     142    }
     143
     144    /**
     145     * @group scope
     146     * @group filter_query
     147     * @group BP_Activity_Query
     148     */
     149    function test_bp_has_activities_just_me_scope_with_no_user_id() {
     150        $u1 = $this->factory->user->create();
     151        $u2 = $this->factory->user->create();
     152
     153        // save the current user and override logged-in user
     154        $old_user = get_current_user_id();
     155        $this->set_current_user( $u1 );
     156
     157        $now = time();
     158
     159        // activity item
     160        $a1 = $this->factory->activity->create( array(
     161            'user_id'   => $u1,
     162            'component' => 'activity',
     163            'type'      => 'activity_update',
     164            'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ),
     165        ) );
     166
     167        // misc activity items
     168
     169        $this->factory->activity->create( array(
     170            'user_id'   => $u2,
     171            'component' => 'activity',
     172            'type'      => 'activity_update',
     173            'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ),
     174        ) );
     175        $this->factory->activity->create( array(
     176            'user_id'   => $u2,
     177            'component' => 'groups',
     178            'item_id'   => 324,
     179            'type'      => 'activity_update',
     180            'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ),
     181        ) );
     182
     183        global $activities_template;
     184
     185        // grab just-me scope with no user ID
     186        // user ID should fallback to logged-in user ID
     187        bp_has_activities( array(
     188            'user_id' => false,
     189            'scope' => 'just-me',
     190        ) );
     191
     192        // assert!
     193        $this->assertEqualSets( array( $a1 ), wp_list_pluck( $activities_template->activities, 'id' ) );
     194
     195        // clean up!
     196        $activities_template = null;
     197        $this->set_current_user( $old_user );
    142198    }
    143199
Note: See TracChangeset for help on using the changeset viewer.