You are here

public function DatabaseExceptionWrapperTest::testPrepareStatementFailOnExecution in Drupal 9

Tests Connection::prepareStatement exceptions on execution.

Core database drivers use PDO emulated statements or the StatementPrefetch class, which defer the statement check to the moment of the execution.

File

core/tests/Drupal/KernelTests/Core/Database/DatabaseExceptionWrapperTest.php, line 71

Class

DatabaseExceptionWrapperTest
Tests exceptions thrown by queries.

Namespace

Drupal\KernelTests\Core\Database

Code

public function testPrepareStatementFailOnExecution() {
  $this
    ->expectException(\PDOException::class);
  $stmt = Database::getConnection()
    ->prepareStatement('bananas', []);
  $stmt
    ->execute();
}