protected function ConfigEntityQueryTest::testCount

Tests count query.

File

drupal/core/modules/system/lib/Drupal/system/Tests/Entity/ConfigEntityQueryTest.php, line 350
Contains \Drupal\system\Tests\ConfigEntityQueryTest.

Class

ConfigEntityQueryTest
Tests the config entity query.

Namespace

Drupal\system\Tests\Entity

Code

protected function testCount() {

  // Test count on no conditions.
  $count = $this->factory
    ->get('config_query_test')
    ->count()
    ->execute();
  $this
    ->assertIdentical($count, count($this->entities));

  // Test count on a complex query.
  $query = $this->factory
    ->get('config_query_test', 'OR');
  $and_condition_1 = $query
    ->andConditionGroup()
    ->condition('id', 1)
    ->condition('label', $this->entities[0]->label);
  $and_condition_2 = $query
    ->andConditionGroup()
    ->condition('id', '2')
    ->condition('label', $this->entities[1]->label);
  $count = $query
    ->condition($and_condition_1)
    ->condition($and_condition_2)
    ->count()
    ->execute();
  $this
    ->assertIdentical($count, 2);
}