You are here

function SelectPagerDefaultTest::testHavingPagerQuery in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Database/SelectPagerDefaultTest.php \Drupal\system\Tests\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/src/Tests/Database/SelectPagerDefaultTest.php, line 113
Contains \Drupal\system\Tests\Database\SelectPagerDefaultTest.

Class

SelectPagerDefaultTest
Tests the pager query select extender.

Namespace

Drupal\system\Tests\Database

Code

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