You are here

public function GNodeSafeModeViewWithAnotherModuleTests::testOutsiderViewAccessWhenAnotherModuleSaysAccessIsOK in Group 7

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

File

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

Class

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

Code

public function testOutsiderViewAccessWhenAnotherModuleSaysAccessIsOK() {
  $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));
  $this
    ->drupalLogin($web_user);
  $this
    ->assertNodeOperationAccess($node->nid, 'view', 403, 'Group node is not accessible by outsider 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 outsider without group view permissions but with other module grant');
  $group_type->outsider_permissions = array(
    'view page node',
  );
  $group_type
    ->save();
  $this
    ->assertNodeOperationAccess($node->nid, 'view', 200, 'Group node is accessible by outsider 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 outsider 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 outsider 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 outsider without group view permissions and without other module grant');
}