Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/05/2014 02:37:30 PM (11 years ago)
Author:
boonebgorges
Message:

Swap bp_group_has_invites() internals for BP_Group_Member_Query, and introduce pagination arguments

See #5423

Props boonebgorges, dcavins

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/testcases/groups/template.php

    r7986 r8045  
    476476            $this_user = new BP_Core_User( $found_users[ $counter ] );
    477477            foreach ( get_object_vars( $this_user ) as $k => $v ) {
     478                // Doesn't matter if the backpat provides *more*
     479                // details than the old method, so we skip cases
     480                // where the BP_Core_User value is empty
     481                if ( empty( $v ) ) {
     482                    continue;
     483                }
     484
    478485                $this->assertEquals( $v, $invites_template->invite->user->{$k} );
    479486            }
     
    481488        endwhile;
    482489    }
     490
     491    /**
     492     * @group bp_group_has_invites
     493     * @group BP_Groups_Invite_Template
     494     */
     495    public function test_bp_group_has_invites_pagination() {
     496        $u1 = $this->create_user( array(
     497            'last_activity' => gmdate( 'Y-m-d H:i:s', time() - 60 ),
     498        ) );
     499
     500        $g = $this->factory->group->create( array(
     501            'creator_id' => $u1,
     502        ) );
     503
     504        $users = array();
     505        for ( $i = 1; $i < 15; $i++ ) {
     506            $users[ $i ] = $this->create_user( array(
     507                'last_activity' => gmdate( 'Y-m-d H:i:s', time() - $i ),
     508            ) );
     509
     510            $this->add_user_to_group( $users[ $i ], $g, array(
     511                'date_modified' => gmdate( 'Y-m-d H:i:s', time() - $i ),
     512                'is_confirmed' => 0,
     513                'inviter_id' => $u1,
     514                'invite_sent' => true,
     515            ) );
     516        }
     517
     518        // Populate the global
     519        bp_group_has_invites( array(
     520            'group_id' => $g,
     521            'user_id' => $u1,
     522            'page' => 2,
     523            'per_page' => 5,
     524        ) );
     525
     526        global $invites_template;
     527
     528        $this->assertEquals( array( $users[ 9 ], $users[ 8 ], $users[ 7 ], $users[ 6 ], $users[ 5 ], ), $invites_template->invites );
     529    }
    483530}
Note: See TracChangeset for help on using the changeset viewer.