function DatabaseRangeQueryTestCase::testRangeQuery

Confirm that range query work and return correct result.

File

drupal/modules/simpletest/tests/database_test.test, line 3131

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.');
}