You are here

public function GNodeWebTestBase::assertNodeOperationAccess in Group 7

Perform an operation on a node.

This will check the response to access some operation via the URL of a node. Note that this just checks the ability to perform the operation and does not actually create or delete a node.

Parameters

int|string $node_identifier: The node nid or node type for create

string $op: An operation such as 'view', 'edit', 'create'

int $expected_response: The expected response code. If the user should not be able to see the 'publish' or 'unpublish' tabs, set this to 403, otherwise 200.

string $msg: (optional) An assertion log message.

Throws

Exception If bad $op param is used

26 calls to GNodeWebTestBase::assertNodeOperationAccess()
GNodeBypassAccessTests::testAnonymousBypassGroupAccess in modules/gnode/tests/gnode.test
Test anonymous user's access to nodes in a group when granted bypass group access.
GNodeBypassAccessTests::testMemberBypassGroupAccess in modules/gnode/tests/gnode.test
Test member user's access to nodes in a group when granted bypass group access.
GNodeBypassAccessTests::testOutsiderBypassGroupAccess in modules/gnode/tests/gnode.test
Test outsider user's access to nodes in a group when granted bypass group access.
GNodeCreateAccessTests::testAnonymousCreateAccess in modules/gnode/tests/gnode.test
Test anonymous user's create access to nodes in a group. This checks via several permissions: create node and administer group.
GNodeCreateAccessTests::testMemberCreateAccess in modules/gnode/tests/gnode.test
Test member user's create access to nodes in a group. This checks via several permissions: create node and administer group.

... See full list

File

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

Class

GNodeWebTestBase
Base class provides a number of helper functions.

Code

public function assertNodeOperationAccess($node_identifier, $op = 'view', $expected_response = 200, $msg = '') {
  switch ($op) {
    case 'view':
      $url = "node/{$node_identifier}";
      break;
    case 'edit':
      $url = "node/{$node_identifier}/edit";
      break;
    case 'delete':
      $url = "node/{$node_identifier}/delete";
      break;
    case 'create':
      $url = "node/add/{$node_identifier}";
      break;
    default:
      throw new Exception('Invalid $op parameter passed to assertNodeOperationAccess: ' . $op);
  }
  $this
    ->drupalGet($url);
  $this
    ->assertResponse($expected_response, $msg);
}