public function GNodeViewAccessTests::testMemberViewAccess in Group 7
Test member user's view access to nodes in a group.
File
- modules/
gnode/ tests/ gnode.test, line 285 - Tests for the gnode module.
Class
- GNodeViewAccessTests
- Test for view access control.
Code
public function testMemberViewAccess() {
$group_type = $this
->createGroupType('example');
$group = $this
->createGroup('example', 'example');
$node = $this
->createNodeInGroup($group->gid);
$web_user = $this
->drupalCreateUser(array(
'access content',
));
$group
->addMember($web_user->uid);
$this
->drupalLogin($web_user);
$this
->assertNodeOperationAccess($node->nid, 'view', 403, 'Group node is not accessible by member without view permissions.');
$this
->assertNodesOnListingPage(array(), 'Group node is not visible on listing pages to member without view permissions.');
$group_type->member_permissions = array(
'view page node',
);
$group_type
->save();
$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.');
$group_type->member_permissions = array(
'administer group',
);
$group_type
->save();
$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.');
$this
->removeNodeFromGroup($node);
$this
->assertNodeOperationAccess($node->nid, 'view', 200, 'Node not in group is accessible by member with standard access content permission.');
$this
->assertNodesOnListingPage(array(
$node->nid,
), 'Node not in group is visible on listing pages to member with standard access content permissions.');
}