function SelectComplexTest::testCountQueryDistinct

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Database/SelectComplexTest.php \Drupal\KernelTests\Core\Database\SelectComplexTest::testCountQueryDistinct()
  2. 10 core/tests/Drupal/KernelTests/Core/Database/SelectComplexTest.php \Drupal\KernelTests\Core\Database\SelectComplexTest::testCountQueryDistinct()
  3. 11.x core/tests/Drupal/KernelTests/Core/Database/SelectComplexTest.php \Drupal\KernelTests\Core\Database\SelectComplexTest::testCountQueryDistinct()

Tests that we can generate a count query from a query with distinct.

File

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

Class

SelectComplexTest
Tests the Select query builder with more complex queries.

Namespace

Drupal\KernelTests\Core\Database

Code

public function testCountQueryDistinct() {
    $query = $this->connection
        ->select('test_task');
    $query->addField('test_task', 'task');
    $query->distinct();
    $count = $query->countQuery()
        ->execute()
        ->fetchField();
    $this->assertEqual($count, 6, 'Counted the correct number of records.');
}

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