NodeQueryAlter::testNodeQueryAlterLowLevelNoAccess

7 node.test NodeQueryAlter::testNodeQueryAlterLowLevelNoAccess()
8 node.test NodeQueryAlter::testNodeQueryAlterLowLevelNoAccess()

Lower-level test of 'node_access' query alter, for user without access.

Verifies that a non-standard table alias can be used, and that a user without node access cannot view the nodes.

File

modules/node/node.test, line 2064
Tests for node.module.

Code

function testNodeQueryAlterLowLevelNoAccess() {
  // User without access should be able to view 0 nodes.
  try {
    $query = db_select('node', 'mytab')
        ->fields('mytab');
    $query->addTag('node_access');
    $query->addMetaData('op', 'view');
    $query->addMetaData('account', $this->noAccessUser);

    $result = $query->execute()->fetchAll();
    $this->assertEqual(count($result), 0, t('User with no access cannot see nodes'));
  }
  catch (Exception $e) {
    $this->fail(t('Altered query is malformed'));
  }
}
Login or register to post comments