Laravel Http::fake ConnectionException

81 Views Asked by At

How to test http macro retry counts on Connection failure?

AppServiceProvider:

Http::macro('host', function () {
            return Http::acceptJson()
                ->retry(5, 600, function (\Exception $exception, PendingRequest $request) {
                    return $exception instanceof ConnectionException;
                });
        });

Feature test:

public function test_connection_exception(): void
{
    Http::preventStrayRequests();

    Http::fake([
        '*' => // I need something here...
    ]);

    Http::assertSentCount(5);
}
0

There are 0 best solutions below