Skip to:
Content

BuddyPress.org

Ticket #6099: 6099.patch

File 6099.patch, 5.2 KB (added by imath, 12 years ago)
  • src/bp-activity/bp-activity-filters.php

    diff --git src/bp-activity/bp-activity-filters.php src/bp-activity/bp-activity-filters.php
    index 494133c..d9e2624 100644
    add_filter( 'bp_activity_set_just-me_scope_args', 'bp_activity_filter_just_me_sc  
    677677function bp_activity_filter_favorites_scope( $retval, $filter ) {
    678678        $favs = bp_activity_get_user_favorites( $filter['user_id'] );
    679679        if ( empty( $favs ) ) {
    680                 return $retval;
     680                $favs = array( 0 );
    681681        }
    682682
    683683        $retval = array(
  • src/bp-friends/bp-friends-activity.php

    diff --git src/bp-friends/bp-friends-activity.php src/bp-friends/bp-friends-activity.php
    index 38b9f2d..055a38c 100644
    function bp_friends_filter_activity_scope( $retval, $filter ) {  
    242242        $friends = friends_get_friend_user_ids( $filter['user_id'] );
    243243
    244244        if ( empty( $friends ) ) {
    245                 return $retval;
     245                $friends = array( 0 );
    246246        }
    247247
    248248        $retval= array(
  • src/bp-groups/bp-groups-activity.php

    diff --git src/bp-groups/bp-groups-activity.php src/bp-groups/bp-groups-activity.php
    index 361ac24..467d6b0 100644
    function bp_groups_filter_activity_scope( $retval, $filter ) {  
    246246        $groups = groups_get_user_groups( $filter['user_id'] );
    247247
    248248        if ( empty( $groups['groups'] ) ) {
    249                 return $retval;
     249                $groups = array( 'groups' => 0 );
    250250        }
    251251
    252252        $retval= array(
  • tests/phpunit/testcases/activity/template.php

    diff --git tests/phpunit/testcases/activity/template.php tests/phpunit/testcases/activity/template.php
    index 8b6e714..e3e01c7 100644
    class BP_Tests_Activity_Template extends BP_UnitTestCase {  
    342342        }
    343343
    344344        /**
     345         * @group scope
     346         * @group filter_query
     347         * @group BP_Activity_Query
     348         */
     349        function test_bp_has_activities_scope_friends_no_items() {
     350                $u1 = $this->factory->user->create();
     351
     352                $now = time();
     353
     354                // Create a random activity
     355                $a1 = $this->factory->activity->create( array(
     356                        'user_id' => $u1,
     357                        'type' => 'activity_update',
     358                        'recorded_time' => date( 'Y-m-d H:i:s', $now ),
     359                ) );
     360
     361                global $activities_template;
     362                $reset_activities_template = $activities_template;
     363
     364                // grab activities from friends scope
     365                bp_has_activities( array(
     366                        'user_id' => $u1,
     367                        'scope' => 'friends',
     368                ) );
     369
     370                // assert!
     371                $this->assertEmpty( $activities_template->activities, 'When a user does not have any friendship, no activities should be fetched when on friends scope' );
     372
     373                // clean up!
     374                $activities_template = $reset_activities_template;
     375        }
     376
     377        /**
     378         * @group scope
     379         * @group filter_query
     380         * @group BP_Activity_Query
     381         */
     382        function test_bp_has_activities_scope_favorites_no_items() {
     383                $u1 = $this->factory->user->create();
     384
     385                $now = time();
     386
     387                // Create a random activity
     388                $a1 = $this->factory->activity->create( array(
     389                        'user_id' => $u1,
     390                        'type' => 'activity_update',
     391                        'recorded_time' => date( 'Y-m-d H:i:s', $now ),
     392                ) );
     393
     394                global $activities_template;
     395                $reset_activities_template = $activities_template;
     396
     397                // grab activities from favorites scope
     398                bp_has_activities( array(
     399                        'user_id' => $u1,
     400                        'scope' => 'favorites',
     401                ) );
     402
     403                // assert!
     404                $this->assertEmpty( $activities_template->activities, 'When a user has not favorited any activity, no activities should be fetched when on favorites scope' );
     405
     406                // clean up!
     407                $activities_template = $reset_activities_template;
     408        }
     409
     410        /**
     411         * @group scope
     412         * @group filter_query
     413         * @group BP_Activity_Query
     414         */
     415        function test_bp_has_activities_scope_groups_no_items() {
     416                $u1 = $this->factory->user->create();
     417
     418                $now = time();
     419
     420                // Create a random activity
     421                $a1 = $this->factory->activity->create( array(
     422                        'user_id' => $u1,
     423                        'type' => 'activity_update',
     424                        'recorded_time' => date( 'Y-m-d H:i:s', $now ),
     425                ) );
     426
     427                global $activities_template;
     428                $reset_activities_template = $activities_template;
     429
     430                // grab activities from groups scope
     431                bp_has_activities( array(
     432                        'user_id' => $u1,
     433                        'scope' => 'groups',
     434                ) );
     435
     436                // assert!
     437                $this->assertEmpty( $activities_template->activities, 'When a user is not a member of any group, no activities should be fetched when on groups scope' );
     438
     439                // clean up!
     440                $activities_template = $reset_activities_template;
     441        }
     442
     443        /**
     444         * @group scope
     445         * @group filter_query
     446         * @group BP_Activity_Query
     447         */
     448        function test_bp_has_activities_scope_mentions_no_items() {
     449                $u1 = $this->factory->user->create();
     450
     451                $now = time();
     452
     453                // Create a random activity
     454                $a1 = $this->factory->activity->create( array(
     455                        'user_id' => $u1,
     456                        'type' => 'activity_update',
     457                        'recorded_time' => date( 'Y-m-d H:i:s', $now ),
     458                ) );
     459
     460                global $activities_template;
     461                $reset_activities_template = $activities_template;
     462
     463                // grab activities from mentions scope
     464                bp_has_activities( array(
     465                        'user_id' => $u1,
     466                        'scope' => 'mentions',
     467                ) );
     468
     469                // assert!
     470                $this->assertEmpty( $activities_template->activities, 'When a user has no mention, no activities should be fetched when on the mentions scope' );
     471
     472                // clean up!
     473                $activities_template = $reset_activities_template;
     474        }
     475
     476        /**
    345477         * @group filter_query
    346478         * @group BP_Activity_Query
    347479         */