You are here

function SelectComplexTest::testDistinct 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::testDistinct()

Tests distinct queries.

File

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

Class

SelectComplexTest
Tests the Select query builder with more complex queries.

Namespace

Drupal\system\Tests\Database

Code

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