You are here

public function SelectComplexTest::testRangeUndo in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/KernelTests/Core/Database/SelectComplexTest.php \Drupal\KernelTests\Core\Database\SelectComplexTest::testRangeUndo()

Tests whether the range property of a select clause can be undone.

File

core/tests/Drupal/KernelTests/Core/Database/SelectComplexTest.php, line 166

Class

SelectComplexTest
Tests the Select query builder with more complex queries.

Namespace

Drupal\KernelTests\Core\Database

Code

public function testRangeUndo() {
  $query = $this->connection
    ->select('test');
  $query
    ->addField('test', 'name');
  $query
    ->addField('test', 'age', 'age');
  $query
    ->range(0, 2);
  $query
    ->range(NULL, NULL);
  $query_result = $query
    ->countQuery()
    ->execute()
    ->fetchField();
  $this
    ->assertEquals(4, $query_result, 'Returned the correct number of rows.');
}