private function runEventuallyConsistentTest()

in src/TestUtils/EventuallyConsistentTestTrait.php [50:80]


    private function runEventuallyConsistentTest(
        callable $func,
        $maxAttempts = null,
        $catchAllExceptions = null
    ) {
        if (is_null($maxAttempts)) {
            $maxAttempts = $this->eventuallyConsistentRetryCount;
        }
        if (is_null($catchAllExceptions)) {
            $catchAllExceptions = $this->catchAllExceptions;
        }
        $attempts = 0;
        while ($attempts < $maxAttempts) {
            try {
                return $func();
            } catch (\PHPUnit\Framework\ExpectationFailedException $testException) {
                // do nothing
            } catch (\Exception $testException) {
                if (!$catchAllExceptions) {
                    throw $testException;
                }
            }
            // Increment the number of attempts, and if we are going to attempt
            // again, run the sleep function.
            $attempts++;
            if ($attempts < $maxAttempts) {
                $this->retrySleepFunc($attempts);
            }
        }
        throw $testException;
    }