Skip to:
Content

BuddyPress.org

Ticket #6169: 6169.unittest.patch

File 6169.unittest.patch, 1.9 KB (added by imath, 11 years ago)
  • tests/phpunit/testcases/activity/template.php

    diff --git tests/phpunit/testcases/activity/template.php tests/phpunit/testcases/activity/template.php
    index f61a61b..cca9e64 100644
    class BP_Tests_Activity_Template extends BP_UnitTestCase { 
    858858        }
    859859
    860860        /**
     861         * @group BP6169
     862         */
     863        public function test_bp_has_activities_private_group_home_scope() {
     864                global $activities_template;
     865                $bp = buddypress();
     866                $reset_current_group = $bp->groups->current_group;
     867                $reset_current_action = $bp->current_action;
     868
     869                $u1 = $this->factory->user->create();
     870                $u2 = $this->factory->user->create();
     871                $u3 = $this->factory->user->create();
     872
     873                $this->set_current_user( $u1 );
     874
     875                $g = $this->factory->group->create( array(
     876                        'status' => 'private',
     877                ) );
     878
     879                groups_join_group( $g, $u2 );
     880                groups_join_group( $g, $u3 );
     881
     882                $a1 = $this->factory->activity->create( array(
     883                        'component' => $bp->groups->id,
     884                        'item_id'   => $g,
     885                        'type'      => 'activity_update',
     886                        'user_id'   => $u2,
     887                        'content'   => 'foo bar',
     888                ) );
     889
     890                $a2 = $this->factory->activity->create( array(
     891                        'component' => $bp->groups->id,
     892                        'item_id'   => $g,
     893                        'type'      => 'activity_update',
     894                        'user_id'   => $u3,
     895                        'content'   => 'bar foo',
     896                ) );
     897
     898                $bp->groups->current_group = groups_get_group( array(
     899                        'group_id'        => $g,
     900                        'populate_extras' => true,
     901                ) );
     902
     903                // On group's home the scope is set to 'home'
     904                $bp->current_action = 'home';
     905
     906                bp_has_activities( array( 'action' => 'activity_update' ) );
     907
     908                $this->assertEqualSets( array( $a1, $a2 ), wp_list_pluck( $activities_template->activities, 'id' ) );
     909
     910                // clean up!
     911                $activities_template = null;
     912                $bp->groups->current_group = $reset_current_group;
     913                $bp->current_action = $reset_current_action;
     914        }
     915
     916        /**
    861917         * Integration test for 'meta_query' param
    862918         */
    863919        function test_bp_has_activities_with_meta_query() {