function FetchTest::testRowCount

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Database/FetchTest.php \Drupal\KernelTests\Core\Database\FetchTest::testRowCount()
  2. 8.9.x core/tests/Drupal/KernelTests/Core/Database/FetchTest.php \Drupal\KernelTests\Core\Database\FetchTest::testRowCount()
  3. 10 core/tests/Drupal/KernelTests/Core/Database/FetchTest.php \Drupal\KernelTests\Core\Database\FetchTest::testRowCount()

Tests that rowCount() throws exception on SELECT query.

File

core/tests/Drupal/KernelTests/Core/Database/FetchTest.php, line 236

Class

FetchTest
Tests the Database system's various fetch capabilities.

Namespace

Drupal\KernelTests\Core\Database

Code

public function testRowCount() : void {
    $result = $this->connection
        ->query('SELECT [name] FROM {test}');
    try {
        $result->rowCount();
        $exception = FALSE;
    } catch (RowCountException) {
        $exception = TRUE;
    }
    $this->assertTrue($exception, 'Exception was thrown');
}

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