You are here

public function ExistingDrupal8StyleDatabaseConnectionInSettingsPhpTest::testExistingDrupal8StyleDatabaseConnectionInSettingsPhp in Drupal 10

Confirms that the site works with Drupal 8 style database connection array.

File

core/tests/Drupal/FunctionalTests/ExistingDrupal8StyleDatabaseConnectionInSettingsPhpTest.php, line 44

Class

ExistingDrupal8StyleDatabaseConnectionInSettingsPhpTest
@group Database

Namespace

Drupal\FunctionalTests

Code

public function testExistingDrupal8StyleDatabaseConnectionInSettingsPhp() {
  $this
    ->drupalLogin($this
    ->drupalCreateUser());
  $this
    ->assertSession()
    ->addressEquals('user/2');
  $this
    ->assertSession()
    ->statusCodeEquals(200);

  // Make sure that we are have tested with the Drupal 8 style database
  // connection array.
  $filename = $this->siteDirectory . '/settings.php';
  $contents = file_get_contents($filename);
  $driver = Database::getConnection()
    ->driver();
  $this
    ->assertStringContainsString("'namespace' => 'Drupal\\\\Core\\\\Database\\\\Driver\\\\{$driver}',", $contents);
  $this
    ->assertStringContainsString("'driver' => '{$driver}',", $contents);
  $this
    ->assertStringNotContainsString("'autoload' => 'core/modules/{$driver}/src/Driver/Database/{$driver}/", $contents);
}