function DriverSpecificConnectionUnitTestBase::waitFor
Wait for a callback to return a truthy value.
Parameters
int|float $timeout: Number of seconds to wait for.
callable $callback: The callback to call.
Return value
mixed The result of the callback.
1 call to DriverSpecificConnectionUnitTestBase::waitFor()
- DriverSpecificConnectionUnitTestBase::assertNoConnection in core/
tests/ Drupal/ KernelTests/ Core/ Database/ DriverSpecificConnectionUnitTestBase.php - Asserts that a connection ID does not exist.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Database/ DriverSpecificConnectionUnitTestBase.php, line 116
Class
- DriverSpecificConnectionUnitTestBase
- Tests management of database connections.
Namespace
Drupal\KernelTests\Core\DatabaseCode
protected function waitFor(int|float $timeout, callable $callback) : mixed {
$start = microtime(TRUE);
$end = $start + $timeout;
do {
$result = call_user_func($callback, $this);
if ($result) {
break;
}
usleep(10000);
} while (microtime(TRUE) < $end);
return $result;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.