public function testThrowsExceptionWhenRetryFunctionReturnsFalse()
{
$actualAttempts = 0;
$hasTriggeredException = false;
$retryFunction = function (\Exception $ex) {
return false;
};
$backoff = new ExponentialBackoff(null, $retryFunction);
$backoff->setDelayFunction($this->delayFunction);
try {
$backoff->execute(function () use(&$actualAttempts) {
$actualAttempts++;
throw new \Exception();
});
} catch (\Exception $ex) {
$hasTriggeredException = true;
}
$this->assertTrue($hasTriggeredException);
$this->assertEquals(1, $actualAttempts);
}