function DriverSpecificConnectionUnitTestBase::testOpenClose

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Database/DriverSpecificConnectionUnitTestBase.php \Drupal\KernelTests\Core\Database\DriverSpecificConnectionUnitTestBase::testOpenClose()
  2. 11.x core/tests/Drupal/KernelTests/Core/Database/DriverSpecificConnectionUnitTestBase.php \Drupal\KernelTests\Core\Database\DriverSpecificConnectionUnitTestBase::testOpenClose()

Tests Database::closeConnection() without query.

@todo getConnectionId() executes a query.

File

core/tests/Drupal/KernelTests/Core/Database/DriverSpecificConnectionUnitTestBase.php, line 103

Class

DriverSpecificConnectionUnitTestBase
Tests management of database connections.

Namespace

Drupal\KernelTests\Core\Database

Code

public function testOpenClose() : void {
    // Close the connection.
    Database::closeConnection(static::TEST_TARGET_CONNECTION);
    // Wait 20ms to give the database engine sufficient time to react.
    usleep(20000);
    // Verify that we are back to the original connection count.
    $this->assertNoConnection($this->id);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.