public function GNodeViewAccessTests::testMemberWithGlobalRoleViewAccess in Group 7
Test member user's view access to nodes in a group when the permission is granted via a global level role.
File
- modules/
gnode/ tests/ gnode.test, line 354 - Tests for the gnode module.
Class
- GNodeViewAccessTests
- Test for view access control.
Code
public function testMemberWithGlobalRoleViewAccess() {
$group_type = $this
->createGroupType('example');
$group = $this
->createGroup('example', 'example');
$group_role = $this
->createRole('example_role');
$node = $this
->createNodeInGroup($group->gid);
$web_user = $this
->drupalCreateUser(array(
'access content',
));
$role_details = array(
'roles' => array(
'example_role',
),
'added_on' => REQUEST_TIME,
'added_by' => 1,
);
$group
->addMember($web_user->uid, $role_details);
$this
->drupalLogin($web_user);
$this
->assertNodeOperationAccess($node->nid, 'view', 403, 'Group node is not accessible by member without view permissions on a global role.');
$this
->assertNodesOnListingPage(array(), 'Group node is not visible on listing pages to member without view permissions on a global role.');
$group_role
->grantPermissions(array(
'view page node',
));
$this
->assertNodeOperationAccess($node->nid, 'view', 200, 'Group node is accessible by member with view permissions.');
$this
->assertNodesOnListingPage(array(
$node->nid,
), 'Group node is visible on listing pages to member with view permissions on a global role.');
$group_role
->revokePermissions(array(
'view page node',
));
$group_role
->grantPermissions(array(
'administer group',
));
$this
->assertNodeOperationAccess($node->nid, 'view', 200, 'Group node is accessible by member with administer group permissions.');
$this
->assertNodesOnListingPage(array(
$node->nid,
), 'Group node is visible on listing pages to member with administer group permissions on a global role.');
$this
->removeNodeFromGroup($node);
$this
->assertNodeOperationAccess($node->nid, 'view', 200, 'Node not in group is accessible by member with global role with standard access content permission.');
$this
->assertNodesOnListingPage(array(
$node->nid,
), 'Node not in group is visible on listing pages to member with global role with standard access content permission.');
}