You are here

public function GNodeSafeModeViewWithAnotherModuleTests::testMemberViewAccessWhenAnotherModuleSaysAccessIsOK in Group 7

Test Group behaviour for member when another module is providing node grants.

File

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

Class

GNodeSafeModeViewWithAnotherModuleTests
Test Group behaviour when another module is providing node grants.

Code

public function testMemberViewAccessWhenAnotherModuleSaysAccessIsOK() {
  $group_type = $this
    ->createGroupType('example');
  $group = $this
    ->createGroup('example', 'example');
  $node = $this
    ->createNodeInGroup($group->gid);
  $web_user = $this
    ->drupalCreateUser(array(
    'access content',
  ));
  $role = user_role_load(reset($web_user->roles));
  $group
    ->addMember($web_user->uid);
  $this
    ->drupalLogin($web_user);
  $this
    ->assertNodeOperationAccess($node->nid, 'view', 403, 'Group node is not accessible by member without group view permissions nor other module grant');
  user_role_grant_permissions($role->rid, array(
    'access content',
    'node test view',
  ));
  $this
    ->assertNodeOperationAccess($node->nid, 'view', 403, 'Group node is not accessible by member without group view permissions but with other module grant');
  $group_type->member_permissions = array(
    'view page node',
  );
  $group_type
    ->save();
  $this
    ->assertNodeOperationAccess($node->nid, 'view', 200, 'Group node is accessible by member with view permissions and other module grant');
  user_role_revoke_permissions($role->rid, array(
    'node test view',
  ));
  $this
    ->assertNodeOperationAccess($node->nid, 'view', 200, 'Group node is accessible by member with view permissions without other module grant');
  user_role_grant_permissions($role->rid, array(
    'access content',
    'node test view',
  ));
  $this
    ->removeNodeFromGroup($node);
  $this
    ->assertNodeOperationAccess($node->nid, 'view', 200, 'Node not in group is accessible by member without group view permissions but with other module grant');
  user_role_revoke_permissions($role->rid, array(
    'node test view',
  ));
  $this
    ->assertNodeOperationAccess($node->nid, 'view', 403, 'Node not in group is not accessible by member without group view permissions and without other module grant');
}