diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-03-07 08:03:45 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-03-07 08:03:45 +0000 |
commit | 9703e5d6e24fb8df2778c5d687128f90079aa023 (patch) | |
tree | d5b65057e4b50950991e688eab820de5f31003a0 /modules/simpletest/tests | |
parent | c4ed4523bf7974355f72abd6218e86e7bed398a6 (diff) | |
download | brdo-9703e5d6e24fb8df2778c5d687128f90079aa023.tar.gz brdo-9703e5d6e24fb8df2778c5d687128f90079aa023.tar.bz2 |
#715476 by Jeremy and Crell: Schema object should respect active database connection (with tests).
Diffstat (limited to 'modules/simpletest/tests')
-rw-r--r-- | modules/simpletest/tests/database_test.test | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/modules/simpletest/tests/database_test.test b/modules/simpletest/tests/database_test.test index 3f3f80008..3dc48b727 100644 --- a/modules/simpletest/tests/database_test.test +++ b/modules/simpletest/tests/database_test.test @@ -244,6 +244,41 @@ class DatabaseConnectionTestCase extends DatabaseTestCase { // Opening a connection after closing it should yield an object different than the original. $this->assertNotIdentical($db1, $db2, t('Opening the default connection after it is closed returns a new object.')); } + + /** + * Tests the connection options of the active database. + */ + function testConnectionOptions() { + $connection_info = Database::getConnectionInfo('default'); + + // Be sure we're connected to the default database. + $db = Database::getConnection('default', 'default'); + $connectionOptions = $db->getConnectionOptions(); + + // In the MySQL driver, the port can be different, so check individual + // options. + $this->assertEqual($connection_info['default']['driver'], $connectionOptions['driver'], t('The default connection info driver matches the current connection options driver.')); + $this->assertEqual($connection_info['default']['database'], $connectionOptions['database'], t('The default connection info database matches the current connection options database.')); + + // Set up identical slave and confirm connection options are identical. + Database::addConnectionInfo('default', 'slave', $connection_info['default']); + $db2 = Database::getConnection('slave', 'default'); + $connectionOptions2 = $db2->getConnectionOptions(); + + // Get a fresh copy of the default connection options. + $connectionOptions = $db->getConnectionOptions(); + $this->assertIdentical($connectionOptions, $connectionOptions2, t('The default and slave connection options are identical.')); + + // Set up a new connection with different connection info. + $test = $connection_info['default']; + $test['database'] .= 'test'; + Database::addConnectionInfo('test', 'default', $test); + $connection_info = Database::getConnectionInfo('test'); + + // Get a fresh copy of the default connection options. + $connectionOptions = $db->getConnectionOptions(); + $this->assertNotEqual($connection_info['default']['database'], $connectionOptions['database'], t('The test connection info database does not match the current connection options database.')); + } } /** |