You are here

public function GNodeEditAccessTests::testAnonymousEditAccess in Group 7

Test anonymous user's edit access to nodes in a group.

File

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

Class

GNodeEditAccessTests
Test for edit access control.

Code

public function testAnonymousEditAccess() {
  $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, 'edit', 403, 'Group node is not editable by anonymous without update any page node permissions');
  $group_type->anonymous_permissions = array(
    'update any page node',
  );
  $group_type
    ->save();
  $this
    ->assertNodeOperationAccess($node->nid, 'edit', 200, 'Group node is editable by anonymous with update any page node permissions');
  $group_type->anonymous_permissions = array(
    'administer group',
  );
  $group_type
    ->save();
  $this
    ->assertNodeOperationAccess($node->nid, 'edit', 200, 'Group node is editable by anonymous with administer group node permissions');
  $this
    ->removeNodeFromGroup($node);
  $this
    ->assertNodeOperationAccess($node->nid, 'edit', 403, 'Node not in group is not editable by anonymous with standard access content permission');
}