You are here

function SelectPagerDefaultTest::testInnerPagerQuery 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::testInnerPagerQuery()

Confirms that a pager query results with an inner pager query are valid.

This is a regression test for #467984.

File

core/modules/system/src/Tests/Database/SelectPagerDefaultTest.php, line 91
Contains \Drupal\system\Tests\Database\SelectPagerDefaultTest.

Class

SelectPagerDefaultTest
Tests the pager query select extender.

Namespace

Drupal\system\Tests\Database

Code

function testInnerPagerQuery() {
  $query = db_select('test', 't')
    ->extend('Drupal\\Core\\Database\\Query\\PagerSelectExtender');
  $query
    ->fields('t', array(
    'age',
  ))
    ->orderBy('age')
    ->limit(5);
  $outer_query = db_select($query);
  $outer_query
    ->addField('subquery', 'age');
  $ages = $outer_query
    ->execute()
    ->fetchCol();
  $this
    ->assertEqual($ages, array(
    25,
    26,
    27,
    28,
  ), 'Inner pager query returned the correct ages.');
}