function StatementTest::testEmptyStatementRewind

Same name in other branches
  1. 10 core/tests/Drupal/KernelTests/Core/Database/StatementTest.php \Drupal\KernelTests\Core\Database\StatementTest::testEmptyStatementRewind()

Tests empty statement rewinding.

File

core/tests/Drupal/KernelTests/Core/Database/StatementTest.php, line 184

Class

StatementTest
Tests the Statement classes.

Namespace

Drupal\KernelTests\Core\Database

Code

public function testEmptyStatementRewind() : void {
    $statement = $this->connection
        ->query('SELECT * FROM {test} WHERE 1 = 0');
    $count = 0;
    foreach ($statement as $row) {
        $count++;
    }
    foreach ($statement as $row) {
        $count++;
    }
    $this->assertEquals(0, $count);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.