NodeQueryAlter::testNodeQueryAlterLowLevelWithAccess

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

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

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

File

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

Code

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

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