You are here

public function SelectPagerDefaultTest::testHavingPagerQuery in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/system/tests/src/Functional/Database/SelectPagerDefaultTest.php \Drupal\Tests\system\Functional\Database\SelectPagerDefaultTest::testHavingPagerQuery()

Confirms that a paging query results with a having expression are valid.

This is a regression test for #467984.

File

core/modules/system/tests/src/Functional/Database/SelectPagerDefaultTest.php, line 118

Class

SelectPagerDefaultTest
Tests the pager query select extender.

Namespace

Drupal\Tests\system\Functional\Database

Code

public function testHavingPagerQuery() {
  $query = Database::getConnection()
    ->select('test', 't')
    ->extend('Drupal\\Core\\Database\\Query\\PagerSelectExtender');
  $query
    ->fields('t', [
    'name',
  ])
    ->orderBy('name')
    ->groupBy('name')
    ->having('MAX(age) > :count', [
    ':count' => 26,
  ])
    ->limit(5);
  $ages = $query
    ->execute()
    ->fetchCol();
  $this
    ->assertEqual($ages, [
    'George',
    'Ringo',
  ], 'Pager query with having expression returned the correct ages.');
}