You are here

function ModuleGrantsBasicTestCase::assertEntityQueryAlter in Module Grants 7

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

File

./module_grants.test, line 660

Class

ModuleGrantsBasicTestCase

Code

function assertEntityQueryAlter($permissions, $count) {
  $permissions += array(
    'access content',
  );
  $account = $this
    ->drupalCreateUser($permissions);
  $msg = t("User with permissions @permissions can see @count node entities.", array(
    '@permissions' => implode(',', $permissions),
    '@count' => $count,
  ));
  $query = new EntityFieldQuery();
  $query
    ->entityCondition('entity_type', 'node')
    ->entityCondition('bundle', 'article')
    ->fieldCondition('body', 'value', 'A', 'STARTS_WITH')
    ->addMetaData('account', $account);
  $result = $query
    ->execute();
  $result_count = isset($result['node']) ? count($result['node']) : 0;
  $this
    ->assertEqual($count, $result_count, $msg);
}