You are here

function WorkbenchAccessTestCase::assertWorkbenchAccessCheck in Workbench Access 7

Simple method for running the same node access checks repeatedly.

Parameters

$nodes: The nodes to check. If one fails, the test fails.

$account: The user account being tested.

$message: The string to prefix in front of the test result message.

$true: Boolean indicator that we want to test TRUE or FALSE on this test.

3 calls to WorkbenchAccessTestCase::assertWorkbenchAccessCheck()
WorkbenchAccessMenuTestCase::testWorkbenchAccessMenu in tests/workbench_access.test
WorkbenchAccessRoleTestCase::testWorkbenchAccessRoles in tests/workbench_access.test
WorkbenchAccessTaxonomyTestCase::testWorkbenchAccessTaxonomy in tests/workbench_access.test

File

tests/workbench_access.test, line 94
Test file for Workbench Access.

Class

WorkbenchAccessTestCase
@file Test file for Workbench Access.

Code

function assertWorkbenchAccessCheck($nodes, $account, $message, $true = TRUE) {

  // Since we change conditions, reset node access.
  drupal_static_reset('node_access');

  // Check the node operations.
  $actions = array(
    'create',
    'update',
    'delete',
  );
  foreach ($actions as $action) {
    foreach ($nodes as $node) {
      $status[$action] = FALSE;
      if ($action == 'create') {
        $result = node_access($action, $node->type, $account);
      }
      else {
        $result = node_access($action, $node, $account);
      }
      if ($result) {
        $status[$action] = TRUE;
        break;
      }
    }
    if ($true) {
      $this
        ->assertTrue(!empty($status[$action]), t('@message. Test user can @action content.', array(
        '@message' => $message,
        '@action' => $action,
      )));
    }
    else {
      $this
        ->assertTrue(empty($status[$action]), t('@message. Test user cannot @action content.', array(
        '@message' => $message,
        '@action' => $action,
      )));
    }
  }
}