function ContentEntityNullStorageTest::testEntityQuery

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Entity/ContentEntityNullStorageTest.php \Drupal\KernelTests\Core\Entity\ContentEntityNullStorageTest::testEntityQuery()
  2. 8.9.x core/tests/Drupal/KernelTests/Core/Entity/ContentEntityNullStorageTest.php \Drupal\KernelTests\Core\Entity\ContentEntityNullStorageTest::testEntityQuery()
  3. 10 core/tests/Drupal/KernelTests/Core/Entity/ContentEntityNullStorageTest.php \Drupal\KernelTests\Core\Entity\ContentEntityNullStorageTest::testEntityQuery()

Tests using entity query with ContentEntityNullStorage.

See also

\Drupal\Core\Entity\Query\Null\Query

File

core/tests/Drupal/KernelTests/Core/Entity/ContentEntityNullStorageTest.php, line 32

Class

ContentEntityNullStorageTest
Tests ContentEntityNullStorage entity query support.

Namespace

Drupal\KernelTests\Core\Entity

Code

public function testEntityQuery() : void {
    $this->assertSame(0, \Drupal::entityQuery('contact_message')->accessCheck(FALSE)
        ->count()
        ->execute(), 'Counting a null storage returns 0.');
    $this->assertSame([], \Drupal::entityQuery('contact_message')->accessCheck(FALSE)
        ->execute(), 'Querying a null storage returns an empty array.');
    $this->assertSame([], \Drupal::entityQuery('contact_message')->accessCheck(FALSE)
        ->condition('contact_form', 'test')
        ->execute(), 'Querying a null storage returns an empty array and conditions are ignored.');
    $this->assertSame([], \Drupal::entityQueryAggregate('contact_message')->accessCheck(FALSE)
        ->aggregate('name', 'AVG')
        ->execute(), 'Aggregate querying a null storage returns an empty array');
}

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