function ConnectionUnitTest::addConnection

Same name in other branches
  1. 7.x modules/simpletest/tests/database_test.test \ConnectionUnitTest::addConnection()

Adds a new database connection info to Database.

4 calls to ConnectionUnitTest::addConnection()
ConnectionUnitTest::testOpenClose in core/tests/Drupal/KernelTests/Core/Database/ConnectionUnitTest.php
Tests Database::closeConnection() without query.
ConnectionUnitTest::testOpenQueryClose in core/tests/Drupal/KernelTests/Core/Database/ConnectionUnitTest.php
Tests Database::closeConnection() with a query.
ConnectionUnitTest::testOpenQueryPrefetchClose in core/tests/Drupal/KernelTests/Core/Database/ConnectionUnitTest.php
Tests Database::closeConnection() with a query and custom prefetch method.
ConnectionUnitTest::testOpenSelectQueryClose in core/tests/Drupal/KernelTests/Core/Database/ConnectionUnitTest.php
Tests Database::closeConnection() with a select query.

File

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

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

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