function StatementTest::testStatementCountTwice
Same name in other branches
- 11.x core/tests/Drupal/KernelTests/Core/Database/StatementTest.php \Drupal\KernelTests\Core\Database\StatementTest::testStatementCountTwice()
Tests counting a statement twice.
We need to use iterator_count() and not assertCount() since the latter would rewind the statement twice anyway.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Database/ StatementTest.php, line 204
Class
- StatementTest
- Tests the Statement classes.
Namespace
Drupal\KernelTests\Core\DatabaseCode
public function testStatementCountTwice() : void {
$statement = $this->connection
->query('SELECT * FROM {test}');
$rowCount = iterator_count($statement);
$this->assertSame(4, $rowCount);
$this->expectError();
$this->expectErrorMessage('Attempted rewinding a StatementInterface object when fetching has already started. Refactor your code to avoid rewinding statement objects.');
$rowCount = iterator_count($statement);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.