You are here

public function GNodeCreateAccessTests::testAnonymousCreateAccess in Group 7

Test anonymous user's create access to nodes in a group. This checks via several permissions: create node and administer group.

File

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

Class

GNodeCreateAccessTests
Test for create access control.

Code

public function testAnonymousCreateAccess() {
  $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');
  $this
    ->assertNodeOperationAccess('page', 'create', 403, 'Page nodes cannot be created by anonymous without create page node permissions');
  $group_type->anonymous_permissions = array(
    'create page node',
  );
  $group_type
    ->save();
  $this
    ->assertNodeOperationAccess('page', 'create', 200, 'Page nodes can be created by anonymous with create page node permission');
  $group_type->anonymous_permissions = array(
    'administer group',
  );
  $group_type
    ->save();
  $this
    ->assertNodeOperationAccess('page', 'create', 200, 'Page nodes can be created by anonymous with administer group permission');
}