function DriverSpecificConnectionUnitTestBase::setUp
Same name in other branches
- 10 core/tests/Drupal/KernelTests/Core/Database/DriverSpecificConnectionUnitTestBase.php \Drupal\KernelTests\Core\Database\DriverSpecificConnectionUnitTestBase::setUp()
- 11.x core/tests/Drupal/KernelTests/Core/Database/DriverSpecificConnectionUnitTestBase.php \Drupal\KernelTests\Core\Database\DriverSpecificConnectionUnitTestBase::setUp()
Overrides DriverSpecificKernelTestBase::setUp
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Database/ DriverSpecificConnectionUnitTestBase.php, line 30
Class
- DriverSpecificConnectionUnitTestBase
- Tests management of database connections.
Namespace
Drupal\KernelTests\Core\DatabaseCode
protected function setUp() : void {
parent::setUp();
// Create an additional connection to monitor the connections being opened
// and closed in this test.
$connection_info = Database::getConnectionInfo();
Database::addConnectionInfo('default', 'monitor', $connection_info['default']);
$this->monitor = Database::getConnection('monitor');
// 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]);
// Add and open a new connection.
Database::getConnection(static::TEST_TARGET_CONNECTION);
// Verify that there is a new connection.
$this->id = $this->getConnectionId();
$this->assertConnection($this->id);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.