You are here

function SelectComplexTest::testCountQueryDistinct in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Database/SelectComplexTest.php \Drupal\system\Tests\Database\SelectComplexTest::testCountQueryDistinct()

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

File

core/modules/system/src/Tests/Database/SelectComplexTest.php, line 259
Contains \Drupal\system\Tests\Database\SelectComplexTest.

Class

SelectComplexTest
Tests the Select query builder with more complex queries.

Namespace

Drupal\system\Tests\Database

Code

function testCountQueryDistinct() {
  $query = db_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.');
}