function StatementTest::testIteratedStatementFetch
Same name in other branches
- 10 core/tests/Drupal/KernelTests/Core/Database/StatementTest.php \Drupal\KernelTests\Core\Database\StatementTest::testIteratedStatementFetch()
Tests statement fetching after a full traversal.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Database/ StatementTest.php, line 52
Class
- StatementTest
- Tests the Statement classes.
Namespace
Drupal\KernelTests\Core\DatabaseCode
public function testIteratedStatementFetch() : void {
$statement = $this->connection
->query('SELECT * FROM {test}');
foreach ($statement as $row) {
$this->assertNotNull($row);
}
$this->assertSame([], $statement->fetchAll());
$this->assertSame([], $statement->fetchAllKeyed());
$this->assertSame([], $statement->fetchAllAssoc('age'));
$this->assertSame([], $statement->fetchCol());
$this->assertFalse($statement->fetch());
$this->assertFalse($statement->fetchObject());
$this->assertFalse($statement->fetchAssoc());
$this->assertFalse($statement->fetchField());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.