Error message
You are browsing documentation for drupal 7.x, which is not supported anymore. Read the updated version of this page for drupal 11.x (the latest version).function DatabaseConnectionTestCase::testConnectionRoutingOverride
Test that connections return appropriate connection objects.
File
-
modules/
simpletest/ tests/ database_test.test, line 237
Class
- DatabaseConnectionTestCase
- Test connection management.
Code
function testConnectionRoutingOverride() {
// Clone the master credentials to a slave connection.
// Note this will result in two independent connection objects that happen
// to point to the same place.
$connection_info = Database ::getConnectionInfo ('default');
Database ::addConnectionInfo ('default', 'slave', $connection_info['default']);
Database ::ignoreTarget ('default', 'slave');
$db1 = Database ::getConnection ('default', 'default');
$db2 = Database ::getConnection ('slave', 'default');
$this->assertIdentical ($db1, $db2, 'Both targets refer to the same connection.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.