function TestSiteApplicationTest::addTestDatabase

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Scripts/TestSiteApplicationTest.php \Drupal\Tests\Scripts\TestSiteApplicationTest::addTestDatabase()
  2. 10 core/tests/Drupal/Tests/Scripts/TestSiteApplicationTest.php \Drupal\Tests\Scripts\TestSiteApplicationTest::addTestDatabase()
  3. 11.x core/tests/Drupal/Tests/Scripts/TestSiteApplicationTest.php \Drupal\Tests\Scripts\TestSiteApplicationTest::addTestDatabase()
  4. 11.x core/tests/Drupal/KernelTests/Scripts/TestSiteApplicationTest.php \Drupal\KernelTests\Scripts\TestSiteApplicationTest::addTestDatabase()

Adds the installed test site to the database connection info.

Parameters

string $db_prefix: The prefix of the installed test site.

Return value

string The database key of the added connection.

4 calls to TestSiteApplicationTest::addTestDatabase()
TestSiteApplicationTest::testInstallScript in core/tests/Drupal/Tests/Scripts/TestSiteApplicationTest.php
@coversNothing
TestSiteApplicationTest::testInstallWithFileWithNoClass in core/tests/Drupal/Tests/Scripts/TestSiteApplicationTest.php
@coversNothing
TestSiteApplicationTest::testInstallWithNonExistingFile in core/tests/Drupal/Tests/Scripts/TestSiteApplicationTest.php
@coversNothing
TestSiteApplicationTest::testInstallWithNonSetupClass in core/tests/Drupal/Tests/Scripts/TestSiteApplicationTest.php
@coversNothing

File

core/tests/Drupal/Tests/Scripts/TestSiteApplicationTest.php, line 319

Class

TestSiteApplicationTest
Tests core/scripts/test-site.php.

Namespace

Drupal\Tests\Scripts

Code

protected function addTestDatabase($db_prefix) {
    $database = Database::convertDbUrlToConnectionInfo(getenv('SIMPLETEST_DB'), $this->root);
    $database['prefix'] = [
        'default' => $db_prefix,
    ];
    $target = __CLASS__ . $db_prefix;
    Database::addConnectionInfo($target, 'default', $database);
    return $target;
}

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