You are here

public function GNodeViewAccessTests::testOutsiderViewAccess in Group 7

Test outsider user's view access to nodes in a group.

File

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

Class

GNodeViewAccessTests
Test for view access control.

Code

public function testOutsiderViewAccess() {
  $group_type = $this
    ->createGroupType('example');
  $group = $this
    ->createGroup('example', 'example');
  $node = $this
    ->createNodeInGroup($group->gid);
  $web_user = $this
    ->drupalCreateUser(array(
    'access content',
  ));
  $this
    ->drupalLogin($web_user);
  $this
    ->assertNodeOperationAccess($node->nid, 'view', 403, 'Group node is not accessible by outsider without view permissions.');
  $this
    ->assertNodesOnListingPage(array(), 'Node in group is not visible on listing pages to outsider without view permissions.');
  $group_type->outsider_permissions = array(
    'view page node',
  );
  $group_type
    ->save();
  $this
    ->assertNodeOperationAccess($node->nid, 'view', 200, 'Group node is accessible by outsider with view permissions.');
  $this
    ->assertNodesOnListingPage(array(
    $node->nid,
  ), 'Node in group is visible on listing pages to outsider with view permissions.');
  $group_type->outsider_permissions = array(
    'administer group',
  );
  $group_type
    ->save();
  $this
    ->assertNodeOperationAccess($node->nid, 'view', 200, 'Group node is accessible by outsider with administer group permissions.');
  $this
    ->assertNodesOnListingPage(array(
    $node->nid,
  ), 'Node in group is visible on listing pages to outsider with administer group permissions.');
  $this
    ->removeNodeFromGroup($node);
  $this
    ->assertNodeOperationAccess($node->nid, 'view', 200, 'Node not in group is accessible by outsider with standard access content permission.');
  $this
    ->assertNodesOnListingPage(array(
    $node->nid,
  ), 'Node not in group is visible on listing pages to outsider with standard access content permission.');
}