You are here

function DatabaseConnectionTestCase::testConnectionClosing in SimpleTest 7

Tests the closing of a database connection.

File

tests/database_test.test, line 235

Class

DatabaseConnectionTestCase
Test connection management.

Code

function testConnectionClosing() {

  // Open the default target so we have an object to compare.
  $db1 = Database::getConnection('default', 'default');

  // Try to close the the default connection, then open a new one.
  Database::closeConnection('default', 'default');
  $db2 = Database::getConnection('default', 'default');

  // 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.'));
}