You are here

public function SelectComplexTest::testDistinct in Drupal 8

Same name and namespace in other branches
  1. 9 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 176

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
    ->assertEqual($query_result, 6, 'Returned the correct number of rows.');
}