You are here

public function ContentEntityNullStorageTest::testEntityQuery in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Entity/ContentEntityNullStorageTest.php \Drupal\system\Tests\Entity\ContentEntityNullStorageTest::testEntityQuery()

Tests using entity query with ContentEntityNullStorage.

See also

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

File

core/modules/system/src/Tests/Entity/ContentEntityNullStorageTest.php, line 37
Contains \Drupal\system\Tests\Entity\ContentEntityNullStorageTest.

Class

ContentEntityNullStorageTest
Tests ContentEntityNullStorage entity query support.

Namespace

Drupal\system\Tests\Entity

Code

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