You are here

public function GNodeBypassAccessTests::testMemberBypassGroupAccess in Group 7

Test member user's access to nodes in a group when granted bypass group access.

File

modules/gnode/tests/gnode.test, line 1009
Tests for the gnode module.

Class

GNodeBypassAccessTests
Test for bypass access control.

Code

public function testMemberBypassGroupAccess() {
  $group_type = $this
    ->createGroupType('example');
  $group = $this
    ->createGroup('example', 'example');
  $node = $this
    ->createNodeInGroup($group->gid);
  $web_user = $this
    ->drupalCreateUser(array(
    'access content',
    'bypass group access',
  ));
  $group
    ->addMember($web_user->uid);
  $this
    ->drupalLogin($web_user);
  $this
    ->assertNodeOperationAccess($node->nid, 'view', 200, 'Group node is accessible by member with bypass group access user permissions');
  $this
    ->assertNodeOperationAccess($node->nid, 'edit', 200, 'Group node is editable by member with bypass group access user permissions');
  $this
    ->assertNodeOperationAccess($node->nid, 'delete', 200, 'Group node is deletable by member with bypass group access user permissions');
  $this
    ->assertNodeOperationAccess('page', 'create', 200, 'Group node is creatable by member with bypass group access user permissions');
  $this
    ->removeNodeFromGroup($node);
  $this
    ->assertNodeOperationAccess($node->nid, 'view', 200, 'Node not in group is accessible by member with bypass group access permission');
  $this
    ->assertNodeOperationAccess($node->nid, 'edit', 403, 'Node not in group is not editable by member with bypass group access permission');
  $this
    ->assertNodeOperationAccess($node->nid, 'delete', 403, 'Node not in group is not deletable by member with bypass group access permission');
}