You are here

function ModuleGrantsBasicTestCase::assertNodeQueryAlter in Module Grants 7

Based on node.test's test methods

Overrides ModuleGrantsBaseTestCase::assertNodeQueryAlter

1 call to ModuleGrantsBasicTestCase::assertNodeQueryAlter()
ModuleGrantsBasicTestCase::testQueryAlter in ./module_grants.test

File

./module_grants.test, line 644

Class

ModuleGrantsBasicTestCase

Code

function assertNodeQueryAlter($permissions, $count) {
  $permissions += array(
    'access content',
  );
  $account = $this
    ->drupalCreateUser($permissions);
  $msg = t("User with permissions @permissions can see @count nodes.", array(
    '@permissions' => implode(',', $permissions),
    '@count' => $count,
  ));
  $query = db_select('node', 'mytab')
    ->fields('mytab');
  $query
    ->addTag('node_access');
  $query
    ->addMetadata('account', $account);
  $result = $query
    ->execute()
    ->fetchAll();
  $this
    ->assertEqual($count, count($result), $msg);
}