You are here

public function SelectPagerDefaultTest::testHavingPagerQuery in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/system/tests/src/Functional/Database/SelectPagerDefaultTest.php \Drupal\Tests\system\Functional\Database\SelectPagerDefaultTest::testHavingPagerQuery()
  2. 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 119

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(PagerSelectExtender::class);
  $query
    ->fields('t', [
    'name',
  ])
    ->orderBy('name')
    ->groupBy('name')
    ->having('MAX([age]) > :count', [
    ':count' => 26,
  ])
    ->limit(5);
  $ages = $query
    ->execute()
    ->fetchCol();
  $this
    ->assertEquals([
    'George',
    'Ringo',
  ], $ages, 'Pager query with having expression returned the correct ages.');
}