You are here

function ModuleGrantsBasicTestCase::testHookNodeAccessAllow in Module Grants 7

File

./module_grants.test, line 583

Class

ModuleGrantsBasicTestCase

Code

function testHookNodeAccessAllow() {
  $permission = 'module_grants_test_access_hook create all';
  $account = $this
    ->drupalCreateUser(array(
    $permission,
    'access content',
  ));
  $this
    ->assertTrue(node_access('create', 'article', $account), t("User with permission @permission can create article", array(
    '@permission' => $permission,
  )));
  $node = $this
    ->drupalCreateNode(array(
    'title' => "Test node dog blue three",
    'type' => 'article',
  ));
  foreach (array(
    'view',
    'update',
    'delete',
  ) as $op) {
    $permission = "module_grants_test_access_hook {$op} all";
    $account = $this
      ->drupalCreateUser(array(
      $permission,
      'access content',
    ));
    $this
      ->assertTrue(node_access($op, $node, $account), t("User with permission @permission can {$op} article node @title", array(
      '@permission' => $permission,
      '@title' => $node->title,
    )));
  }
}