function DatabaseExceptionWrapperTest::testPrepareQuery

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();
}

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