You are here

public function FetchTest::testRowCount in Drupal 9

Same name and namespace in other branches
  1. 8 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 185

Class

FetchTest
Tests the Database system's various fetch capabilities.

Namespace

Drupal\KernelTests\Core\Database

Code

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