function EntityQueryTest::testAccessCheckSpecified

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Entity/EntityQueryTest.php \Drupal\KernelTests\Core\Entity\EntityQueryTest::testAccessCheckSpecified()
  2. 11.x core/tests/Drupal/KernelTests/Core/Entity/EntityQueryTest.php \Drupal\KernelTests\Core\Entity\EntityQueryTest::testAccessCheckSpecified()

Test the accessCheck method is called.

File

core/tests/Drupal/KernelTests/Core/Entity/EntityQueryTest.php, line 1439

Class

EntityQueryTest
Tests Entity Query functionality.

Namespace

Drupal\KernelTests\Core\Entity

Code

public function testAccessCheckSpecified() : void {
    $this->expectException(QueryException::class);
    $this->expectExceptionMessage('Entity queries must explicitly set whether the query should be access checked or not. See Drupal\\Core\\Entity\\Query\\QueryInterface::accessCheck().');
    // We are purposely testing an entity query without access check, so we need
    // to tell PHPStan to ignore this.
    // @phpstan-ignore-next-line
    $this->storage
        ->getQuery()
        ->execute();
}

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