You are here

protected function NodeAccessExampleTestCase::checkNodeAccess in Examples for Developers 7

Helper function.

Test if a node with the id $nid has expected access grants.

Parameters

int $nid: Node that will be checked.

Return value

bool Checker ran successfully

1 call to NodeAccessExampleTestCase::checkNodeAccess()
NodeAccessExampleTestCase::testNodeAccessBasic in node_access_example/node_access_example.test
Test the "private" node access.

File

node_access_example/node_access_example.test, line 293
Tests for Node Access example module.

Class

NodeAccessExampleTestCase
Functional tests for the Node Access Example module.

Code

protected function checkNodeAccess($nid, $grant_view, $grant_update, $grant_delete) {

  // Test if node can be viewed.
  if (!$this
    ->checkResponse($grant_view, 'node/' . $nid)) {
    return FALSE;
  }

  // Test if private node can be edited.
  if (!$this
    ->checkResponse($grant_update, 'node/' . $nid . '/edit')) {
    return FALSE;
  }

  // Test if private node can be deleted.
  if (!$this
    ->checkResponse($grant_delete, 'node/' . $nid . '/delete')) {
    return FALSE;
  }
  return TRUE;
}