function ExistingDrupal8StyleDatabaseConnectionInSettingsPhpTest::testExistingDrupal8StyleDatabaseConnectionInSettingsPhp

Same name and namespace in other branches
  1. 10 core/tests/Drupal/FunctionalTests/ExistingDrupal8StyleDatabaseConnectionInSettingsPhpTest.php \Drupal\FunctionalTests\ExistingDrupal8StyleDatabaseConnectionInSettingsPhpTest::testExistingDrupal8StyleDatabaseConnectionInSettingsPhp()
  2. 11.x core/tests/Drupal/FunctionalTests/ExistingDrupal8StyleDatabaseConnectionInSettingsPhpTest.php \Drupal\FunctionalTests\ExistingDrupal8StyleDatabaseConnectionInSettingsPhpTest::testExistingDrupal8StyleDatabaseConnectionInSettingsPhp()

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

File

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

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

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