function DriverSpecificConnectionUnitTestBase::testOpenQueryPrefetchClose
Same name in other branches
- 9 core/tests/Drupal/KernelTests/Core/Database/DriverSpecificConnectionUnitTestBase.php \Drupal\KernelTests\Core\Database\DriverSpecificConnectionUnitTestBase::testOpenQueryPrefetchClose()
- 11.x core/tests/Drupal/KernelTests/Core/Database/DriverSpecificConnectionUnitTestBase.php \Drupal\KernelTests\Core\Database\DriverSpecificConnectionUnitTestBase::testOpenQueryPrefetchClose()
Tests Database::closeConnection() with a query and custom prefetch method.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Database/ DriverSpecificConnectionUnitTestBase.php, line 132
Class
- DriverSpecificConnectionUnitTestBase
- Tests management of database connections.
Namespace
Drupal\KernelTests\Core\DatabaseCode
public function testOpenQueryPrefetchClose() : void {
// Execute a query.
Database::getConnection(static::TEST_TARGET_CONNECTION)->query($this->getQuery()['show_tables'])
->fetchCol();
// 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.