You are here

public function DatabaseExceptionWrapperTest::testPrepareQuery in Drupal 9

Tests deprecation of Connection::prepareQuery.

@group legacy

File

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

Class

DatabaseExceptionWrapperTest
Tests exceptions thrown by queries.

Namespace

Drupal\KernelTests\Core\Database

Code

public function testPrepareQuery() {
  $this
    ->expectDeprecation('Connection::prepareQuery() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. Use ::prepareStatement() instead. See https://www.drupal.org/node/3137786');
  $this
    ->expectException(\PDOException::class);
  $stmt = Database::getConnection()
    ->prepareQuery('bananas');
  $stmt
    ->execute();
}