$this->
assertCount(1,
$records, 'There is only one record.'
);
} /**
* Confirms that we can fetch a record to an associative array explicitly.
*/
public function testQueryFetchArray() { $records =
[];
$result =
$this->connection->
query('SELECT [name] FROM {test} WHERE [age] = :age',
[':age' => 25
],
['fetch' => \PDO::FETCH_ASSOC
]);
foreach ($result as $record) { $records[] =
$record;
$this->
assertIsArray($record);
$this->
assertArrayHasKey('name',
$record);
$this->
assertSame('John',
$record['name'
]);
} $this->
assertCount(1,
$records, 'There is only one record.'
);
} /**
* Confirms that we can fetch a record into a new instance of a custom class.
*
* @see \Drupal\system\Tests\Database\FakeRecord
*/