You are here

public function DrupalTest::testEntityQueryAggregate in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/DrupalTest.php \Drupal\Tests\Core\DrupalTest::testEntityQueryAggregate()
  2. 10 core/tests/Drupal/Tests/Core/DrupalTest.php \Drupal\Tests\Core\DrupalTest::testEntityQueryAggregate()

Tests the entityQueryAggregate() method.

@covers ::entityQueryAggregate

File

core/tests/Drupal/Tests/Core/DrupalTest.php, line 288

Class

DrupalTest
Tests the Drupal class.

Namespace

Drupal\Tests\Core

Code

public function testEntityQueryAggregate() {
  $query = $this
    ->createMock(QueryAggregateInterface::class);
  $storage = $this
    ->createMock(EntityStorageInterface::class);
  $storage
    ->expects($this
    ->once())
    ->method('getAggregateQuery')
    ->with('OR')
    ->willReturn($query);
  $entity_type_manager = $this
    ->createMock(EntityTypeManagerInterface::class);
  $entity_type_manager
    ->expects($this
    ->once())
    ->method('getStorage')
    ->with('test_entity')
    ->willReturn($storage);
  $this
    ->setMockContainerService('entity_type.manager', $entity_type_manager);
  $this
    ->assertInstanceOf(QueryAggregateInterface::class, \Drupal::entityQueryAggregate('test_entity', 'OR'));
}