diff --git a/.phpunit.cache/test-results b/.phpunit.cache/test-results new file mode 100644 index 0000000..75d01ee --- /dev/null +++ b/.phpunit.cache/test-results @@ -0,0 +1 @@ +{"version":"pest_2.34.2","defects":[],"times":{"P\\Tests\\Feature\\AsyncRequestTest::__pest_evaluable_an_asynchronous_request_can_be_made_successfully":0.234,"P\\Tests\\Feature\\AsyncRequestTest::__pest_evaluable_an_asynchronous_request_can_handle_an_exception_properly":0.21,"P\\Tests\\Feature\\AsyncRequestTest::__pest_evaluable_an_asynchronous_response_will_still_be_passed_through_response_middleware":0.014,"P\\Tests\\Feature\\AsyncRequestTest::__pest_evaluable_an_asynchronous_request_will_return_a_custom_response":0.004,"P\\Tests\\Feature\\Body\\HasBodyTest::__pest_evaluable_the_default_body_is_loaded":0.002,"P\\Tests\\Feature\\Body\\HasBodyTest::__pest_evaluable_the_http_sender_properly_sends_it":0.001,"P\\Tests\\Feature\\Body\\HasFormBodyTest::__pest_evaluable_the_default_body_is_loaded":0.001,"P\\Tests\\Feature\\Body\\HasFormBodyTest::__pest_evaluable_the_http_sender_properly_sends_it":0.001,"P\\Tests\\Feature\\Body\\HasJsonBodyTest::__pest_evaluable_the_default_body_is_loaded":0.001,"P\\Tests\\Feature\\Body\\HasJsonBodyTest::__pest_evaluable_the_content_type_header_is_set_in_the_pending_request":0,"P\\Tests\\Feature\\Body\\HasJsonBodyTest::__pest_evaluable_the_http_sender_properly_sends_it":0.001,"P\\Tests\\Feature\\Body\\HasMultipartBodyTest::__pest_evaluable_the_default_body_is_loaded":0.003,"P\\Tests\\Feature\\Body\\HasMultipartBodyTest::__pest_evaluable_the_http_sender_properly_sends_it":0.005,"P\\Tests\\Feature\\Body\\HasXmlBodyTest::__pest_evaluable_the_default_body_is_loaded":0.001,"P\\Tests\\Feature\\Body\\HasXmlBodyTest::__pest_evaluable_the_content_type_header_is_set_in_the_pending_request":0,"P\\Tests\\Feature\\Body\\HasXmlBodyTest::__pest_evaluable_the_http_sender_properly_sends_it":0.001,"P\\Tests\\Feature\\ConfigTest::__pest_evaluable_default_guzzle_config_options_are_sent":0.001,"P\\Tests\\Feature\\ConfigTest::__pest_evaluable_you_can_pass_additional_guzzle_config_options_and_they_are_merged_from_the_connector_and_request":0.001,"P\\Tests\\Feature\\ConfigTest::__pest_evaluable_you_can_pass_additional_headers_that_will_be_merged_with_the_default_headers_from_the_psr_request":0.001,"P\\Tests\\Feature\\GlobalMiddlewareTest::__pest_evaluable_the_global_middleware_of_the_http_client_factory_is_also_applied_to_saloon_requests":0.143,"P\\Tests\\Feature\\HttpEventsTest::__pest_evaluable_the_http_events_are_fired_when_using_the_http_sender":0.275,"P\\Tests\\Feature\\HttpEventsTest::__pest_evaluable_the_http_events_are_fired_when_using_the_http_sender_with_asynchronous_events":0.296,"P\\Tests\\Feature\\HttpEventsTest::__pest_evaluable_the_http_events_are_fired_when_using_request_pools":0.239,"P\\Tests\\Feature\\PoolTest::__pest_evaluable_you_can_create_a_pool_on_a_connector":0.222,"P\\Tests\\Feature\\PoolTest::__pest_evaluable_if_a_pool_has_a_request_that_cannot_connect_it_will_be_caught_in_the_handleException_callback":0.006,"P\\Tests\\Feature\\RequestTest::__pest_evaluable_a_request_can_be_made_successfully":0.148,"P\\Tests\\Feature\\RequestTest::__pest_evaluable_a_request_can_handle_an_exception_properly":0.102,"P\\Tests\\Feature\\RequestTest::__pest_evaluable_a_request_will_throw_an_exception_if_a_connection_error_happens":0.002}} \ No newline at end of file diff --git a/composer.json b/composer.json index 14b2fd0..a9826c2 100644 --- a/composer.json +++ b/composer.json @@ -13,15 +13,15 @@ "homepage": "https://github.com/sammyjo20", "require": { "php": "^8.1", - "illuminate/http": "^10.32|^11.0", + "illuminate/http": "^10.32 || ^11.0", "saloonphp/saloon": "^3.1" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3.5", - "pestphp/pest": "^1.23|^2.34", + "orchestra/testbench": "^8.0 || ^9.0", + "pestphp/pest": "^1.23 || ^2.34", "phpstan/phpstan": "^1.9", - "spatie/ray": "^1.33", - "orchestra/testbench": "^8.0|^9.0" + "spatie/ray": "^1.33" }, "minimum-stability": "stable", "autoload": { diff --git a/phpunit.xml b/phpunit.xml index 8f4b58c..0017caa 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,18 +1,14 @@ - - - - ./tests - - - - - ./app - ./src - - + + + + ./tests + + + + + ./app + ./src + + diff --git a/src/HttpSender.php b/src/HttpSender.php index ec0df8c..9b203f4 100644 --- a/src/HttpSender.php +++ b/src/HttpSender.php @@ -99,8 +99,8 @@ protected function processPromise(RequestInterface $psrRequest, PromiseInterface // it back down the "otherwise"/"catch" chain return $promise - ->then(function (HttpResponse|TransferException $result) { - $exception = $result instanceof TransferException ? $result : $result->toException(); + ->then(function (HttpResponse|TransferException|ConnectionException $result) { + $exception = $result instanceof TransferException || $result instanceof ConnectionException ? $result : $result->toException(); if ($exception instanceof Throwable) { throw $exception; @@ -114,7 +114,7 @@ function (HttpResponse $response) use ($psrRequest, $pendingRequest) { }, ) ->otherwise( - function (HttpRequestException|TransferException $exception) use ($pendingRequest, $psrRequest) { + function (HttpRequestException|TransferException|ConnectionException $exception) use ($pendingRequest, $psrRequest) { // When the exception wasn't a HttpRequestException, we'll throw a fatal // exception as this is likely a ConnectException, but it will // catch any new ones Guzzle release. diff --git a/tests/Feature/PoolTest.php b/tests/Feature/PoolTest.php index 67de824..ccfa91c 100644 --- a/tests/Feature/PoolTest.php +++ b/tests/Feature/PoolTest.php @@ -2,6 +2,7 @@ declare(strict_types=1); +use Illuminate\Http\Client\ConnectionException; use Saloon\Http\Response; use Saloon\Http\PendingRequest; use Saloon\HttpSender\HttpSender; @@ -64,7 +65,7 @@ $pool->withExceptionHandler(function (FatalRequestException $ex) use (&$count) { expect($ex)->toBeInstanceOf(FatalRequestException::class); - expect($ex->getPrevious())->toBeInstanceOf(ConnectException::class); + expect($ex->getPrevious())->toBeInstanceOf(ConnectionException::class); expect($ex->getPendingRequest())->toBeInstanceOf(PendingRequest::class); $count++; diff --git a/tests/Feature/RequestTest.php b/tests/Feature/RequestTest.php index 70a2df0..a0e0d08 100644 --- a/tests/Feature/RequestTest.php +++ b/tests/Feature/RequestTest.php @@ -1,4 +1,6 @@ -¬