From 42b945aabeb13706ab319eb359120b066adfc112 Mon Sep 17 00:00:00 2001 From: Alexander Lentner Date: Thu, 19 Jan 2023 07:51:27 +0100 Subject: [PATCH] Add `conflict` method to http client response --- src/Illuminate/Http/Client/Response.php | 10 ++++++++++ tests/Http/HttpClientTest.php | 11 +++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/Illuminate/Http/Client/Response.php b/src/Illuminate/Http/Client/Response.php index 2e6e2d556c6c..07370262129a 100644 --- a/src/Illuminate/Http/Client/Response.php +++ b/src/Illuminate/Http/Client/Response.php @@ -214,6 +214,16 @@ public function notFound() return $this->status() === 404; } + /** + * Determine if the response was a 409 "Conflict" response. + * + * @return bool + */ + public function conflict() + { + return $this->status() === 409; + } + /** * Determine if the response indicates a client or server error occurred. * diff --git a/tests/Http/HttpClientTest.php b/tests/Http/HttpClientTest.php index 327e97192d73..58bbdb12be1d 100644 --- a/tests/Http/HttpClientTest.php +++ b/tests/Http/HttpClientTest.php @@ -89,6 +89,17 @@ public function testNotFoundResponse() $this->assertTrue($response->notFound()); } + public function testConflictResponse() + { + $this->factory->fake([ + 'laravel.com' => $this->factory::response('', 409), + ]); + + $response = $this->factory->post('http://laravel.com'); + + $this->assertTrue($response->conflict()); + } + public function testResponseBodyCasting() { $this->factory->fake([