You are here

function DatabaseSelectComplexTestCase::testRange in Drupal 7

Test range queries. The SQL clause varies with the database.

File

modules/simpletest/tests/database_test.test, line 2140

Class

DatabaseSelectComplexTestCase
Test more complex select statements.

Code

function testRange() {
  $query = db_select('test');
  $name_field = $query
    ->addField('test', 'name');
  $age_field = $query
    ->addField('test', 'age', 'age');
  $query
    ->range(0, 2);
  $result = $query
    ->execute();
  $num_records = 0;
  foreach ($result as $record) {
    $num_records++;
  }
  $this
    ->assertEqual($num_records, 2, 'Returned the correct number of rows.');
}