You are here

function ConnectionTest::testConnectionClosing in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/system/src/Tests/Database/ConnectionTest.php \Drupal\system\Tests\Database\ConnectionTest::testConnectionClosing()

Tests the closing of a database connection.

File

core/modules/system/src/Tests/Database/ConnectionTest.php, line 75
Contains \Drupal\system\Tests\Database\ConnectionTest.

Class

ConnectionTest
Tests of the core database system.

Namespace

Drupal\system\Tests\Database

Code

function testConnectionClosing() {

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

  // Try to close 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, 'Opening the default connection after it is closed returns a new object.');
}