You are here

public function GNodeCreateAccessTests::testMemberCreateAccess in Group 7

Test member 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 925
Tests for the gnode module.

Class

GNodeCreateAccessTests
Test for create access control.

Code

public function testMemberCreateAccess() {
  $group_type = $this
    ->createGroupType('example');
  $group = $this
    ->createGroup('example', 'example');
  $web_user = $this
    ->drupalCreateUser(array(
    'access content',
  ));
  $group
    ->addMember($web_user->uid);
  $this
    ->drupalLogin($web_user);
  $this
    ->assertNodeOperationAccess('page', 'create', 403, 'Page nodes cannot be created by member without create page node permission');
  $group_type->member_permissions = array(
    'create page node',
  );
  $group_type
    ->save();
  $this
    ->assertNodeOperationAccess('page', 'create', 200, 'Page nodes can be created by member with create page node permission');
  $group_type->member_permissions = array(
    'administer group',
  );
  $group_type
    ->save();
  $this
    ->assertNodeOperationAccess('page', 'create', 200, 'Page nodes can be created by member with administer group permission');
}