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([