You are here

public function OgAccessModeratedGroup::testMembershipRequest in Organic groups 7.2

Test membership creation attempt made via direct API calls, by non-admins.

File

og_access/og_access.test, line 453
Test organic groups access module.

Class

OgAccessModeratedGroup
Tests moderated group memberships.

Code

public function testMembershipRequest() {

  // The call of drupalLogin() in setUp() is not effective for API calls,
  // switching users here to test the permission check.
  global $user;
  $current_user = $user;
  $user = $this->user;

  // Save user as a member of the group, without passing state.
  $this->user->og_user_node[LANGUAGE_NONE][0]['target_id'] = $this->group->nid;
  user_save($this->user);
  $user = $current_user;

  // User's membership should not exist.
  $membership = og_get_membership('node', $this->group->nid, 'user', $this->user->uid);
  $this
    ->assertFalse(is_object($membership), t('Non-admins cannot add members to private groups.'));
}