You are here

protected function ConnectionUnitTest::addConnection in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/KernelTests/Core/Database/ConnectionUnitTest.php \Drupal\KernelTests\Core\Database\ConnectionUnitTest::addConnection()
  2. 9 core/tests/Drupal/KernelTests/Core/Database/ConnectionUnitTest.php \Drupal\KernelTests\Core\Database\ConnectionUnitTest::addConnection()

Adds a new database connection info to Database.

File

core/tests/Drupal/KernelTests/Core/Database/ConnectionUnitTest.php, line 73

Class

ConnectionUnitTest
Tests management of database connections.

Namespace

Drupal\KernelTests\Core\Database

Code

protected function addConnection() {

  // Add a new target to the connection, by cloning the current connection.
  $connection_info = Database::getConnectionInfo();
  Database::addConnectionInfo('default', static::TEST_TARGET_CONNECTION, $connection_info['default']);

  // Verify that the new target exists.
  $info = Database::getConnectionInfo();

  // New connection info found.
  $this
    ->assertSame($connection_info['default'], $info[static::TEST_TARGET_CONNECTION]);
}