You are here

function DatabaseFetch2TestCase::testQueryFetchNum in SimpleTest 7

File

tests/database_test.test, line 349

Class

DatabaseFetch2TestCase
Test fetch actions, part 2.

Code

function testQueryFetchNum() {
  $records = array();
  $result = db_query('SELECT name FROM {test} WHERE age = :age', array(
    ':age' => 25,
  ), array(
    'fetch' => PDO::FETCH_NUM,
  ));
  foreach ($result as $record) {
    $records[] = $record;
    if ($this
      ->assertTrue(is_array($record), t('Record is an array.'))) {
      $this
        ->assertIdentical($record[0], 'John', t('Record can be accessed numerically.'));
    }
  }
  $this
    ->assertIdentical(count($records), 1, 'There is only one record');
}