function SelectComplexTest::testHavingCountQuery

Tests having queries.

File

drupal/core/modules/system/lib/Drupal/system/Tests/Database/SelectComplexTest.php, line 210
Definition of Drupal\system\Tests\Database\SelectComplexTest.

Class

SelectComplexTest
Tests more complex select statements.

Namespace

Drupal\system\Tests\Database

Code

function testHavingCountQuery() {
  $query = db_select('test')
    ->extend('Drupal\\Core\\Database\\Query\\PagerSelectExtender')
    ->groupBy('age')
    ->having('age + 1 > 0');
  $query
    ->addField('test', 'age');
  $query
    ->addExpression('age + 1');
  $count = count($query
    ->execute()
    ->fetchCol());
  $this
    ->assertEqual($count, 4, 'Counted the correct number of records.');
}