From d83363d98a6817a4d96e5a0446fabdb4b206be61 Mon Sep 17 00:00:00 2001 From: Taylor Maguire Date: Thu, 24 Jun 2021 07:13:14 -0700 Subject: [PATCH] [8.x] Get statusText from Response protected property (#37795) * Get statusText from Response * Add Test for getStatusText * Update ResponseTrait.php * Update HttpResponseTest.php Co-authored-by: Taylor Otwell --- src/Illuminate/Http/ResponseTrait.php | 10 ++++++++++ tests/Http/HttpResponseTest.php | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/src/Illuminate/Http/ResponseTrait.php b/src/Illuminate/Http/ResponseTrait.php index a255bcf9376b..d632a4b55081 100644 --- a/src/Illuminate/Http/ResponseTrait.php +++ b/src/Illuminate/Http/ResponseTrait.php @@ -32,6 +32,16 @@ public function status() return $this->getStatusCode(); } + /** + * Get the status text for the response. + * + * @return string + */ + public function statusText() + { + return $this->statusText; + } + /** * Get the content of the response. * diff --git a/tests/Http/HttpResponseTest.php b/tests/Http/HttpResponseTest.php index 0674b77118c4..7fa141ac7f31 100755 --- a/tests/Http/HttpResponseTest.php +++ b/tests/Http/HttpResponseTest.php @@ -113,6 +113,13 @@ public function testSetAndRetrieveStatusCode() $this->assertSame(404, $response->getStatusCode()); } + public function testSetStatusCodeAndRetrieveStatusText() + { + $response = new Response('foo'); + $response->setStatusCode(404); + $this->assertSame('Not Found', $response->statusText()); + } + public function testOnlyInputOnRedirect() { $response = new RedirectResponse('foo.bar');