Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/29/2014 12:35:30 AM (12 years ago)
Author:
r-a-y
Message:

Cache the group invite count for a user.

This commit:

  • Caches calls to BP_Groups_Member::get_invite_count_for_user()
  • Invalidates the group invite count cache on various actions
  • Adds a unit test

See #5414

File:
1 edited

Legend:

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

    r8133 r8200  
    578578                $this->set_current_user( $old_user );
    579579        }
     580
     581        /**
     582         * @group counts
     583         */
     584        public function test_get_invite_count_for_user() {
     585                $u1 = $this->create_user();
     586                $u2 = $this->create_user();
     587                $g = $this->factory->group->create( array( 'creator_id' => $u1 ) );
     588
     589                // create invitation
     590                groups_invite_user( array(
     591                        'user_id'    => $u2,
     592                        'group_id'   => $g,
     593                        'inviter_id' => $u1,
     594                ) );
     595
     596                // send the invite
     597                // this function is imperative to set the 'invite_sent' flag in the DB
     598                // why is this separated from groups_invite_user()?
     599                // @see groups_screen_group_invite()
     600                groups_send_invites( $u1, $g );
     601
     602                // assert invite count
     603                $this->assertEquals( 1, groups_get_invite_count_for_user( $u2 ) );
     604
     605                // accept the invite and reassert
     606                groups_accept_invite( $u2, $g );
     607                $this->assertEquals( 0, groups_get_invite_count_for_user( $u2 ) );
     608        }
    580609}
Note: See TracChangeset for help on using the changeset viewer.