You are here

public function SelectPagerDefaultTest::testInnerPagerQuery 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::testInnerPagerQuery()
  2. 10 core/modules/system/tests/src/Functional/Database/SelectPagerDefaultTest.php \Drupal\Tests\system\Functional\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/tests/src/Functional/Database/SelectPagerDefaultTest.php, line 94

Class

SelectPagerDefaultTest
Tests the pager query select extender.

Namespace

Drupal\Tests\system\Functional\Database

Code

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