You are here

public function SelectComplexTest::testDistinct in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/KernelTests/Core/Database/SelectComplexTest.php \Drupal\KernelTests\Core\Database\SelectComplexTest::testDistinct()

Tests distinct queries.

File

core/tests/Drupal/KernelTests/Core/Database/SelectComplexTest.php, line 180

Class

SelectComplexTest
Tests the Select query builder with more complex queries.

Namespace

Drupal\KernelTests\Core\Database

Code

public function testDistinct() {
  $query = $this->connection
    ->select('test_task');
  $query
    ->addField('test_task', 'task');
  $query
    ->distinct();
  $query_result = $query
    ->countQuery()
    ->execute()
    ->fetchField();
  $this
    ->assertEquals(6, $query_result, 'Returned the correct number of rows.');
}