You are here

function SelectComplexTest::testRange in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Database/SelectComplexTest.php \Drupal\system\Tests\Database\SelectComplexTest::testRange()

Tests range queries.

The SQL clause varies with the database.

File

core/modules/system/src/Tests/Database/SelectComplexTest.php, line 151
Contains \Drupal\system\Tests\Database\SelectComplexTest.

Class

SelectComplexTest
Tests the Select query builder with more complex queries.

Namespace

Drupal\system\Tests\Database

Code

function testRange() {
  $query = db_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.');
}