public function SelectComplexTest::testHavingCountQuery in Drupal 8
Same name and namespace in other branches
- 9 core/tests/Drupal/KernelTests/Core/Database/SelectComplexTest.php \Drupal\KernelTests\Core\Database\SelectComplexTest::testHavingCountQuery()
Tests having queries.
File
- core/
tests/ Drupal/ KernelTests/ Core/ Database/ SelectComplexTest.php, line 208
Class
- SelectComplexTest
- Tests the Select query builder with more complex queries.
Namespace
Drupal\KernelTests\Core\DatabaseCode
public function testHavingCountQuery() {
$query = $this->connection
->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.');
}