function NodeQueryAlterTest::testNodeQueryAlterWithRevisions

Same name in other branches
  1. 9 core/modules/node/tests/src/Functional/NodeQueryAlterTest.php \Drupal\Tests\node\Functional\NodeQueryAlterTest::testNodeQueryAlterWithRevisions()
  2. 10 core/modules/node/tests/src/Functional/NodeQueryAlterTest.php \Drupal\Tests\node\Functional\NodeQueryAlterTest::testNodeQueryAlterWithRevisions()
  3. 11.x core/modules/node/tests/src/Functional/NodeQueryAlterTest.php \Drupal\Tests\node\Functional\NodeQueryAlterTest::testNodeQueryAlterWithRevisions()

Tests 'node_access' query alter with revision-enabled nodes.

File

core/modules/node/tests/src/Functional/NodeQueryAlterTest.php, line 90

Class

NodeQueryAlterTest
Tests that node access queries are properly altered by the node module.

Namespace

Drupal\Tests\node\Functional

Code

public function testNodeQueryAlterWithRevisions() {
    // Execute a query that only deals with the 'node_revision' table.
    try {
        $query = \Drupal::entityTypeManager()->getStorage('node')
            ->getQuery();
        $result = $query->allRevisions()
            ->execute();
        $this->assertCount(4, $result, 'User with access can see correct nodes');
    } catch (\Exception $e) {
        $this->fail('Altered query is malformed');
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.