You are here

public function SelectComplexTest::testRange in Drupal 8

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

Tests range queries.

The SQL clause varies with the database.

File

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

Class

SelectComplexTest
Tests the Select query builder with more complex queries.

Namespace

Drupal\KernelTests\Core\Database

Code

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