You are here

public function ConnectionTest::testLegacyDatabaseDriverInRootDriversDirectory in Drupal 9

Tests the deprecation of Drupal 8 style database drivers.

@group legacy

File

core/tests/Drupal/Tests/Core/Database/ConnectionTest.php, line 736

Class

ConnectionTest
Tests the Connection class.

Namespace

Drupal\Tests\Core\Database

Code

public function testLegacyDatabaseDriverInRootDriversDirectory() {
  $this
    ->expectDeprecation('Support for database drivers located in the "drivers/lib/Drupal/Driver/Database" directory is deprecated in drupal:9.1.0 and is removed in drupal:10.0.0. Contributed and custom database drivers should be provided by modules and use the namespace "Drupal\\MODULE_NAME\\Driver\\Database\\DRIVER_NAME". See https://www.drupal.org/node/3123251');
  $namespace = 'Drupal\\Driver\\Database\\Stub';
  $mock_pdo = $this
    ->createMock(StubPDO::class);
  $connection = new StubConnection($mock_pdo, [
    'namespace' => $namespace,
  ], [
    '"',
    '"',
  ]);
  $this
    ->assertEquals($namespace, $connection
    ->getConnectionOptions()['namespace']);
}