1 database_test.test DatabaseRangeQueryTestCase::testRangeQuery()

Confirm that range query work and return correct result.

File

core/modules/simpletest/tests/database_test.test, line 2986
Database tests.

Class

DatabaseRangeQueryTestCase
Range query tests.

Code

function testRangeQuery() {
  // Test if return correct number of rows.
  $range_rows = db_query_range("SELECT name FROM {system} ORDER BY name", 2, 3)->fetchAll();
  $this->assertEqual(count($range_rows), 3, 'Range query work and return correct number of rows.');

  // Test if return target data.
  $raw_rows = db_query('SELECT name FROM {system} ORDER BY name')->fetchAll();
  $raw_rows = array_slice($raw_rows, 2, 3);
  $this->assertEqual($range_rows, $raw_rows, 'Range query work and return target data.');
}