public function ConnectionTest::testDestructBcLayer in Drupal 9
Tests Connection::__destruct().
@group legacy
File
- core/
tests/ Drupal/ Tests/ Core/ Database/ ConnectionTest.php, line 391
Class
- ConnectionTest
- Tests the Connection class.
Namespace
Drupal\Tests\Core\DatabaseCode
public function testDestructBcLayer() {
$this
->expectDeprecation('Drupal\\Core\\Database\\Connection::destroy() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. Move custom database destruction logic to __destruct(). See https://www.drupal.org/node/3142866');
$mock_pdo = $this
->createMock(StubPDO::class);
$fake_connection = new class($mock_pdo, [
'namespace' => Driver::class,
]) extends StubConnection {
public function destroy() {
parent::destroy();
}
};
// Destroy the object which will result in the Connection::__destruct()
// calling Connection::destroy() and a deprecation error being triggered.
// @see \Drupal\KernelTests\Core\Database\ConnectionUnitTest for tests that
// connection object destruction does not trigger deprecations unless
// Connection::destroy() is overridden.
$fake_connection = NULL;
}