Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/25/2014 02:52:12 PM (11 years ago)
Author:
boonebgorges
Message:

Add unit test for bp_group_has_invites()

This test merely checks to see that the $invites_template global is populated
correcltly with invitation-related info after the loop is initialized. It will
be used to ensure backward compatibility after any potential changes related to

File:
1 edited

Legend:

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

    r7330 r7984  
    408408        $this->assertEquals( array( $u1, $u3, $u2, ), $ids );
    409409    }
     410
     411    /**
     412     * @group bp_group_has_invites
     413     * @group BP_Groups_Invite_Template
     414     */
     415    public function test_bp_group_has_invites_template_structure() {
     416        $u1 = $this->create_user( array(
     417            'last_activity' => gmdate( 'Y-m-d H:i:s', time() - 60 ),
     418        ) );
     419        $u2 = $this->create_user( array(
     420            'last_activity' => gmdate( 'Y-m-d H:i:s', time() - 600 ),
     421        ) );
     422        $u3 = $this->create_user( array(
     423            'last_activity' => gmdate( 'Y-m-d H:i:s', time() - 6000 ),
     424        ) );
     425        $u4 = $this->create_user( array(
     426            'last_activity' => gmdate( 'Y-m-d H:i:s', time() - 60000 ),
     427        ) );
     428
     429
     430        $g = $this->factory->group->create( array(
     431            'creator_id' => $u1,
     432        ) );
     433
     434        $m2 = $this->add_user_to_group( $u2, $g, array(
     435            'date_modified' => gmdate( 'Y-m-d H:i:s', time() - 60*60*24 ),
     436            'is_confirmed' => 0,
     437            'inviter_id' => $u1,
     438            'invite_sent' => true,
     439        ) );
     440
     441        $m3 = $this->add_user_to_group( $u3, $g, array(
     442            'date_modified' => gmdate( 'Y-m-d H:i:s', time() - 60*60*12 ),
     443            'is_confirmed' => 0,
     444            'inviter_id' => $u1,
     445            'invite_sent' => true,
     446        ) );
     447
     448        $m4 = $this->add_user_to_group( $u4, $g, array(
     449            'date_modified' => gmdate( 'Y-m-d H:i:s', time() - 60*60*36 ),
     450            'is_confirmed' => 1,
     451            'inviter_id' => $u1,
     452            'invite_sent' => true,
     453        ) );
     454
     455        // Populate the global
     456        bp_group_has_invites( array(
     457            'group_id' => $g,
     458            'user_id' => $u1,
     459        ) );
     460
     461        global $invites_template;
     462
     463        $found_users = array(
     464            0 => $u2,
     465            1 => $u3,
     466        );
     467
     468        // Invites array
     469        $this->assertEquals( $found_users, $invites_template->invites );
     470
     471        // Make sure user is set when loop starts
     472        $counter = 0;
     473        while ( bp_group_invites() ) : bp_group_the_invite();
     474            $this->assertEquals( $g, $invites_template->invite->group_id );
     475            $this->assertEquals( $found_users[ $counter ], $invites_template->invite->user->id );
     476            $counter++;
     477        endwhile;
     478    }
    410479}
Note: See TracChangeset for help on using the changeset viewer.