function DatabaseExceptionWrapperTest::testHandleQueryExceptionDeprecation
Tests deprecation of Connection::handleQueryException.
@group legacy
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Database/ DatabaseExceptionWrapperTest.php, line 57
Class
- DatabaseExceptionWrapperTest
- Tests exceptions thrown by queries.
Namespace
Drupal\KernelTests\Core\DatabaseCode
public function testHandleQueryExceptionDeprecation() : void {
$this->expectDeprecation('Passing a StatementInterface object as a $query argument to Drupal\\Core\\Database\\Connection::query is deprecated in drupal:9.2.0 and is removed in drupal:10.0.0. Call the execute method from the StatementInterface object directly instead. See https://www.drupal.org/node/3154439');
$this->expectDeprecation('Connection::handleQueryException() is deprecated in drupal:9.2.0 and is removed in drupal:10.0.0. Get a handler through $this->exceptionHandler() instead, and use one of its methods. See https://www.drupal.org/node/3187222');
$this->expectException(DatabaseExceptionWrapper::class);
$stmt = Database::getConnection()->prepareStatement('SELECT * FROM {does_not_exist}', []);
Database::getConnection()->query($stmt);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.