You are here

public function SelectPagerDefaultTest::testInnerPagerQuery in Drupal 9

Same name and namespace in other branches
  1. 8 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 95

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(PagerSelectExtender::class);
  $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
    ->assertEquals([
    25,
    26,
    27,
    28,
  ], $ages, 'Inner pager query returned the correct ages.');
}