diff options
Diffstat (limited to 'modules/simpletest/tests')
-rw-r--r-- | modules/simpletest/tests/database_test.test | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/modules/simpletest/tests/database_test.test b/modules/simpletest/tests/database_test.test index 80b7dc26b..377baa2e3 100644 --- a/modules/simpletest/tests/database_test.test +++ b/modules/simpletest/tests/database_test.test @@ -168,6 +168,22 @@ class DatabaseConnectionTestCase extends DatabaseTestCase { $this->assertNotNull($db1, t('default connection is a real connection object.')); $this->assertNotNull($db2, t('slave connection is a real connection object.')); $this->assertNotIdentical($db1, $db2, t('Each target refers to a different connection.')); + + // Try to open those targets another time, that should return the same objects. + $db1b = Database::getConnection('default', 'default'); + $db2b = Database::getConnection('default', 'slave'); + $this->assertIdentical($db1, $db1b, t('A second call to getConnection() returns the same object.')); + $this->assertIdentical($db2, $db2b, t('A second call to getConnection() returns the same object.')); + + // Try to open an unknown target. + $unknown_target = $this->randomName(); + $db3 = Database::getConnection('default', $unknown_target); + $this->assertNotNull($db3, t('Opening an unknown target returns a real connection object.')); + $this->assertIdentical($db1, $db3, t('An unknown target opens the default connection.')); + + // Try to open that unknown target another time, that should return the same object. + $db3b = Database::getConnection('default', $unknown_target); + $this->assertIdentical($db3, $db3b, t('A second call to getConnection() returns the same object.')); } /** |