laravel / framework

The Laravel Framework.
https://laravel.com
MIT License
32.64k stars 11.04k forks source link

[11.x] Http client: record request when faking connection exception #53530

Closed gdebrauwer closed 6 days ago

gdebrauwer commented 6 days ago

I added support for faking a connection exception in a test (see https://github.com/laravel/framework/pull/53485), but I noticed that the request was not being recorded. That means asserting how many requests were sent is currently not correct. This PR fixes that.


Http::fake(['https://laravel.com' => Http::failedConnection()]);

try {
    Http::get('https://laravel.com')
} catch (ConnectionException) {
}

Http::assertSentCount(1); // This would fail before this PR