function StatementTest::testPartiallyIteratedStatementFetchAllKeyed
Same name in other branches
- 10 core/tests/Drupal/KernelTests/Core/Database/StatementTest.php \Drupal\KernelTests\Core\Database\StatementTest::testPartiallyIteratedStatementFetchAllKeyed()
Tests statement fetchAllKeyed after a partial traversal.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Database/ StatementTest.php, line 102
Class
- StatementTest
- Tests the Statement classes.
Namespace
Drupal\KernelTests\Core\DatabaseCode
public function testPartiallyIteratedStatementFetchAllKeyed() : void {
$statement = $this->connection
->query('SELECT * FROM {test}');
for ($i = 0; $i < 2; $i++) {
$statement->fetch();
}
$expected = [
"3" => "Ringo",
"4" => "Paul",
];
$this->assertSame($expected, $statement->fetchAllKeyed());
$this->assertSame([], $statement->fetchAllKeyed());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.