function NodeQueryAlterTest::testNodeQueryAlterLowLevelWithAccess in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/modules/node/src/Tests/NodeQueryAlterTest.php \Drupal\node\Tests\NodeQueryAlterTest::testNodeQueryAlterLowLevelWithAccess()
Tests '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
- core/
modules/ node/ src/ Tests/ NodeQueryAlterTest.php, line 58 - Contains \Drupal\node\Tests\NodeQueryAlterTest.
Class
- NodeQueryAlterTest
- Tests that node access queries are properly altered by the node module.
Namespace
Drupal\node\TestsCode
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, 'User with access can see correct nodes');
} catch (\Exception $e) {
$this
->fail(t('Altered query is malformed'));
}
}