function ConnectionUnitTest::addConnection

Same name in other branches
  1. 8.9.x core/tests/Drupal/KernelTests/Core/Database/ConnectionUnitTest.php \Drupal\KernelTests\Core\Database\ConnectionUnitTest::addConnection()

Adds a new database connection info to Database.

4 calls to ConnectionUnitTest::addConnection()
ConnectionUnitTest::testOpenClose in modules/simpletest/tests/database_test.test
Tests Database::closeConnection() without query.
ConnectionUnitTest::testOpenQueryClose in modules/simpletest/tests/database_test.test
Tests Database::closeConnection() with a query.
ConnectionUnitTest::testOpenQueryPrefetchClose in modules/simpletest/tests/database_test.test
Tests Database::closeConnection() with a query and custom prefetch method.
ConnectionUnitTest::testOpenSelectQueryClose in modules/simpletest/tests/database_test.test
Tests Database::closeConnection() with a select query.

File

modules/simpletest/tests/database_test.test, line 4330

Class

ConnectionUnitTest
Tests management of database connections.

Code

protected function addConnection() {
    // Add a new target to the connection, by cloning the current connection.
    $connection_info = Database::getConnectionInfo($this->key);
    Database::addConnectionInfo($this->key, $this->target, $connection_info[$this->originalTarget]);
    // Verify that the new target exists.
    $info = Database::getConnectionInfo($this->key);
    // Note: Custom assertion message to not expose database credentials.
    $this->assertIdentical($info[$this->target], $connection_info[$this->key], 'New connection info found.');
}

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