function SelectComplexTest::testDistinct

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Database/SelectComplexTest.php \Drupal\KernelTests\Core\Database\SelectComplexTest::testDistinct()
  2. 10 core/tests/Drupal/KernelTests/Core/Database/SelectComplexTest.php \Drupal\KernelTests\Core\Database\SelectComplexTest::testDistinct()
  3. 11.x 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.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.