You are here

public function GNodeSafeModeViewWithAnotherModuleTests::testAnonymousViewAccessWhenAnotherModuleSaysAccessIsOK in Group 7

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

File

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

Class

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

Code

public function testAnonymousViewAccessWhenAnotherModuleSaysAccessIsOK() {
  $role = user_role_load_by_name('anonymous user');
  user_role_grant_permissions($role->rid, array(
    'access content',
  ));
  $group_type = $this
    ->createGroupType('example');
  $group = $this
    ->createGroup('example', 'example');
  $node = $this
    ->createNodeInGroup($group->gid);
  $this
    ->assertNodeOperationAccess($node->nid, 'view', 403, 'Group node is not accessible by anonymous 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 anonymous without group view permissions but with other module grant');
  $group_type->anonymous_permissions = array(
    'view page node',
  );
  $group_type
    ->save();
  $this
    ->assertNodeOperationAccess($node->nid, 'view', 200, 'Group node is accessible by anonymous 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 anonymous 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 anonymous 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 anonymous without group view permissions and without other module grant');
}