Skip to content

Commit 8412fd4

Browse files
committed
Fix not clone to ResponseTrait::withStatus()
1 parent 8aa92ce commit 8412fd4

File tree

8 files changed

+0
-134
lines changed

8 files changed

+0
-134
lines changed

src/ResponseTrait.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,6 @@ public function withStatus($code, $reasonPhrase = ''): ResponseInterface
9090
));
9191
}
9292

93-
if ($code === $this->statusCode && $reasonPhrase === $this->reasonPhrase) {
94-
return $this;
95-
}
96-
9793
$new = clone $this;
9894
$new->setStatus($code, $reasonPhrase);
9995
return $new;

tests/EmptyResponseTest.php

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -70,25 +70,6 @@ public function testWithStatusAndCustomReasonPhrase(): void
7070
self::assertEquals($customPhrase, $response->getReasonPhrase());
7171
}
7272

73-
public function testWithStatusHasNotBeenChangedCodeAndHasBeenChangedReasonPhrase(): void
74-
{
75-
$response = $this->response->withStatus(EmptyResponse::STATUS_CREATED, $customPhrase = 'Custom Phrase');
76-
self::assertNotEquals($this->response, $response);
77-
self::assertEquals(EmptyResponse::STATUS_CREATED, $response->getStatusCode());
78-
self::assertEquals($customPhrase, $response->getReasonPhrase());
79-
}
80-
81-
public function testWithStatusHasNotBeenChangedNotClone(): void
82-
{
83-
$response = $this->response->withStatus(
84-
EmptyResponse::STATUS_NO_CONTENT,
85-
EmptyResponse::PHRASES[EmptyResponse::STATUS_NO_CONTENT]
86-
);
87-
self::assertEquals($this->response, $response);
88-
self::assertEquals(EmptyResponse::STATUS_NO_CONTENT, $response->getStatusCode());
89-
self::assertEquals(EmptyResponse::PHRASES[EmptyResponse::STATUS_NO_CONTENT], $response->getReasonPhrase());
90-
}
91-
9273
public function testWithStatusPassingOnlyCodeHasNotBeenChangedNotClone(): void
9374
{
9475
$response = $this->response->withStatus(EmptyResponse::STATUS_NO_CONTENT);

tests/HtmlResponseTest.php

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -115,25 +115,6 @@ public function testWithStatusHasNotBeenChangedCodeAndHasBeenChangedReasonPhrase
115115
self::assertEquals($customPhrase, $response->getReasonPhrase());
116116
}
117117

118-
public function testWithStatusHasNotBeenChangedNotClone(): void
119-
{
120-
$response = $this->response->withStatus(
121-
HtmlResponse::STATUS_OK,
122-
HtmlResponse::PHRASES[HtmlResponse::STATUS_OK]
123-
);
124-
self::assertEquals($this->response, $response);
125-
self::assertEquals(HtmlResponse::STATUS_OK, $response->getStatusCode());
126-
self::assertEquals(HtmlResponse::PHRASES[HtmlResponse::STATUS_OK], $response->getReasonPhrase());
127-
}
128-
129-
public function testWithStatusPassingOnlyCodeHasNotBeenChangedNotClone(): void
130-
{
131-
$response = $this->response->withStatus(HtmlResponse::STATUS_OK);
132-
self::assertEquals($this->response, $response);
133-
self::assertEquals(HtmlResponse::STATUS_OK, $response->getStatusCode());
134-
self::assertEquals(HtmlResponse::PHRASES[HtmlResponse::STATUS_OK], $response->getReasonPhrase());
135-
}
136-
137118
/**
138119
* @return array
139120
*/

tests/JsonResponseTest.php

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -262,25 +262,6 @@ public function testWithStatusHasNotBeenChangedCodeAndHasBeenChangedReasonPhrase
262262
self::assertEquals($customPhrase, $response->getReasonPhrase());
263263
}
264264

265-
public function testWithStatusHasNotBeenChangedNotClone(): void
266-
{
267-
$response = $this->response->withStatus(
268-
JsonResponse::STATUS_OK,
269-
JsonResponse::PHRASES[JsonResponse::STATUS_OK]
270-
);
271-
self::assertEquals($this->response, $response);
272-
self::assertEquals(JsonResponse::STATUS_OK, $response->getStatusCode());
273-
self::assertEquals(JsonResponse::PHRASES[JsonResponse::STATUS_OK], $response->getReasonPhrase());
274-
}
275-
276-
public function testWithStatusPassingOnlyCodeHasNotBeenChangedNotClone(): void
277-
{
278-
$response = $this->response->withStatus(JsonResponse::STATUS_OK);
279-
self::assertEquals($this->response, $response);
280-
self::assertEquals(JsonResponse::STATUS_OK, $response->getStatusCode());
281-
self::assertEquals(JsonResponse::PHRASES[JsonResponse::STATUS_OK], $response->getReasonPhrase());
282-
}
283-
284265
/**
285266
* @return array
286267
*/

tests/RedirectResponseTest.php

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -108,25 +108,6 @@ public function testWithStatusHasNotBeenChangedCodeAndHasBeenChangedReasonPhrase
108108
self::assertEquals($customPhrase, $response->getReasonPhrase());
109109
}
110110

111-
public function testWithStatusHasNotBeenChangedNotClone(): void
112-
{
113-
$response = $this->response->withStatus(
114-
RedirectResponse::STATUS_FOUND,
115-
RedirectResponse::PHRASES[RedirectResponse::STATUS_FOUND]
116-
);
117-
self::assertEquals($this->response, $response);
118-
self::assertEquals(RedirectResponse::STATUS_FOUND, $response->getStatusCode());
119-
self::assertEquals(RedirectResponse::PHRASES[RedirectResponse::STATUS_FOUND], $response->getReasonPhrase());
120-
}
121-
122-
public function testWithStatusPassingOnlyCodeHasNotBeenChangedNotClone(): void
123-
{
124-
$response = $this->response->withStatus(RedirectResponse::STATUS_FOUND);
125-
self::assertEquals($this->response, $response);
126-
self::assertEquals(RedirectResponse::STATUS_FOUND, $response->getStatusCode());
127-
self::assertEquals(RedirectResponse::PHRASES[RedirectResponse::STATUS_FOUND], $response->getReasonPhrase());
128-
}
129-
130111
/**
131112
* @return array
132113
*/

tests/ResponseTest.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -77,22 +77,6 @@ public function testWithStatusHasNotBeenChangedCodeAndHasBeenChangedReasonPhrase
7777
self::assertEquals($customPhrase, $response->getReasonPhrase());
7878
}
7979

80-
public function testWithStatusHasNotBeenChangedNotClone(): void
81-
{
82-
$response = $this->response->withStatus(Response::STATUS_OK, Response::PHRASES[Response::STATUS_OK]);
83-
self::assertEquals($this->response, $response);
84-
self::assertEquals(Response::STATUS_OK, $response->getStatusCode());
85-
self::assertEquals(Response::PHRASES[Response::STATUS_OK], $response->getReasonPhrase());
86-
}
87-
88-
public function testWithStatusPassingOnlyCodeHasNotBeenChangedNotClone(): void
89-
{
90-
$response = $this->response->withStatus(Response::STATUS_OK);
91-
self::assertEquals($this->response, $response);
92-
self::assertEquals(Response::STATUS_OK, $response->getStatusCode());
93-
self::assertEquals(Response::PHRASES[Response::STATUS_OK], $response->getReasonPhrase());
94-
}
95-
9680
/**
9781
* @return array
9882
*/

tests/TextResponseTest.php

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -115,25 +115,6 @@ public function testWithStatusHasNotBeenChangedCodeAndHasBeenChangedReasonPhrase
115115
self::assertEquals($customPhrase, $response->getReasonPhrase());
116116
}
117117

118-
public function testWithStatusHasNotBeenChangedNotClone(): void
119-
{
120-
$response = $this->response->withStatus(
121-
TextResponse::STATUS_OK,
122-
TextResponse::PHRASES[TextResponse::STATUS_OK]
123-
);
124-
self::assertEquals($this->response, $response);
125-
self::assertEquals(TextResponse::STATUS_OK, $response->getStatusCode());
126-
self::assertEquals(TextResponse::PHRASES[TextResponse::STATUS_OK], $response->getReasonPhrase());
127-
}
128-
129-
public function testWithStatusPassingOnlyCodeHasNotBeenChangedNotClone(): void
130-
{
131-
$response = $this->response->withStatus(TextResponse::STATUS_OK);
132-
self::assertEquals($this->response, $response);
133-
self::assertEquals(TextResponse::STATUS_OK, $response->getStatusCode());
134-
self::assertEquals(TextResponse::PHRASES[TextResponse::STATUS_OK], $response->getReasonPhrase());
135-
}
136-
137118
/**
138119
* @return array
139120
*/

tests/XmlResponseTest.php

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -115,25 +115,6 @@ public function testWithStatusHasNotBeenChangedCodeAndHasBeenChangedReasonPhrase
115115
self::assertEquals($customPhrase, $response->getReasonPhrase());
116116
}
117117

118-
public function testWithStatusHasNotBeenChangedNotClone(): void
119-
{
120-
$response = $this->response->withStatus(
121-
XmlResponse::STATUS_OK,
122-
XmlResponse::PHRASES[XmlResponse::STATUS_OK]
123-
);
124-
self::assertEquals($this->response, $response);
125-
self::assertEquals(XmlResponse::STATUS_OK, $response->getStatusCode());
126-
self::assertEquals(XmlResponse::PHRASES[XmlResponse::STATUS_OK], $response->getReasonPhrase());
127-
}
128-
129-
public function testWithStatusPassingOnlyCodeHasNotBeenChangedNotClone(): void
130-
{
131-
$response = $this->response->withStatus(XmlResponse::STATUS_OK);
132-
self::assertEquals($this->response, $response);
133-
self::assertEquals(XmlResponse::STATUS_OK, $response->getStatusCode());
134-
self::assertEquals(XmlResponse::PHRASES[XmlResponse::STATUS_OK], $response->getReasonPhrase());
135-
}
136-
137118
/**
138119
* @return array
139120
*/

0 commit comments

Comments
 (0)