You are here

function ModuleGrantsBaseTestCase::assertNonBaseTableViewAccess in Module Grants 7

1 call to ModuleGrantsBaseTestCase::assertNonBaseTableViewAccess()
ModuleGrantsBaseTestCase::assetNodeViewAccess in ./module_grants.test
node_accesses: array of node title => true/false

File

./module_grants.test, line 241

Class

ModuleGrantsBaseTestCase

Code

function assertNonBaseTableViewAccess($node_accesses, $account) {
  $tid = $this->term->tid;
  $this
    ->drupalGet("taxonomy/term/{$tid}");
  $this->nodes_visible = array();
  foreach ($this
    ->xpath("//a[text()='Read more']") as $link) {
    $this
      ->assertTrue(preg_match('|node/(\\d+)$|', (string) $link['href'], $matches), 'Read more points to a node');
    $node = node_load($matches[1]);
    $this->nodes_visible[$node->title] = $node;
  }
  foreach ($node_accesses as $node_title => $access) {
    $msg = t("Node '@title' is @access on taxonomy term {$tid} page for user with permissions @permissions, lenient mode @lenient.", array(
      '@title' => $node_title,
      '@access' => $access ? 'visible' : 'not visible',
      '@permissions' => implode(',', $this
        ->getUserPermissions($account)),
      '@lenient' => variable_get('module_grants_lenient', true) ? 'on' : 'off',
    ));
    $this
      ->assertEqual($access, isset($this->nodes_visible[$node_title]), $msg);
  }
}