public function GNodeDeleteAccessTests::testAnonymousDeleteAccess in Group 7
Test anonymous user's delete access to nodes in a group. This checks via several permissions: the delete any node, delete own node and administer group.
File
- modules/
gnode/ tests/ gnode.test, line 685 - Tests for the gnode module.
Class
- GNodeDeleteAccessTests
- Test for delete access control.
Code
public function testAnonymousDeleteAccess() {
$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, 'delete', 403, 'Group node is not deletable by anonymous without update any page node permissions');
$group_type->anonymous_permissions = array(
'delete any page node',
);
$group_type
->save();
$this
->assertNodeOperationAccess($node->nid, 'delete', 200, 'Group node is deletable by anonymous with update any page node permissions');
$group_type->anonymous_permissions = array(
'administer group',
);
$group_type
->save();
$this
->assertNodeOperationAccess($node->nid, 'delete', 200, 'Group node is deletable by anonymous with administer group node permissions');
$this
->removeNodeFromGroup($node);
$this
->assertNodeOperationAccess($node->nid, 'delete', 403, 'Node not in group is not deletable by anonymous with standard access content permission');
}