function NodeQueryAlterTest::testNodeQueryAlterLowLevelNoAccess
Same name in other branches
- 9 core/modules/node/tests/src/Functional/NodeQueryAlterTest.php \Drupal\Tests\node\Functional\NodeQueryAlterTest::testNodeQueryAlterLowLevelNoAccess()
- 8.9.x core/modules/node/tests/src/Functional/NodeQueryAlterTest.php \Drupal\Tests\node\Functional\NodeQueryAlterTest::testNodeQueryAlterLowLevelNoAccess()
- 10 core/modules/node/tests/src/Functional/NodeQueryAlterTest.php \Drupal\Tests\node\Functional\NodeQueryAlterTest::testNodeQueryAlterLowLevelNoAccess()
Tests '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
-
core/
modules/ node/ tests/ src/ Functional/ NodeQueryAlterTest.php, line 127
Class
- NodeQueryAlterTest
- Tests that node access queries are properly altered by the node module.
Namespace
Drupal\Tests\node\FunctionalCode
public function testNodeQueryAlterLowLevelNoAccess() : void {
// User without access should be able to view 0 nodes.
try {
$query = Database::getConnection()->select('node', 'n')
->fields('n');
$query->addTag('node_access');
$query->addMetaData('op', 'view');
$query->addMetaData('account', $this->noAccessUser);
$result = $query->execute()
->fetchAll();
$this->assertCount(0, $result, 'User with no access cannot see nodes');
} catch (\Exception) {
$this->fail('Altered query is malformed');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.