Skip to content

Commit 947b2a8

Browse files
committed
fix: The setStatusCode method can not be called.
1 parent 53fccd5 commit 947b2a8

2 files changed

Lines changed: 4 additions & 21 deletions

File tree

system/HTTP/DownloadResponse.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -242,15 +242,7 @@ public function getStatusCode(): int
242242
*/
243243
public function setStatusCode(int $code, string $reason = '')
244244
{
245-
if ($code !== 200)
246-
{
247-
throw HTTPException::forInvalidStatusCode($code);
248-
}
249-
250-
if ( ! empty($reason) && $this->reason !== $reason)
251-
{
252-
$this->reason = $reason;
253-
}
245+
throw DownloadException::forCannotSetStatusCode($code, $reason);
254246
}
255247

256248
//--------------------------------------------------------------------

tests/system/HTTP/DownloadResponseTest.php

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,12 @@ public function testCanGetStatusCode()
2323
$this->assertSame(200, $response->getStatusCode());
2424
}
2525

26-
public function testCanSetCustomReasonCode()
26+
public function testCantSetStatusCode()
2727
{
2828
$response = new DownloadResponse('unit-test.txt', true);
2929

30-
$response->setStatusCode(200, 'Not the mama');
31-
32-
$this->assertSame('Not the mama', $response->getReason());
33-
}
34-
35-
public function testCantSet200OtherThanStatusCode()
36-
{
37-
$response = new DownloadResponse('unit-test.txt', true);
38-
39-
$this->expectException(HTTPException::class);
40-
$response->setStatusCode(999);
30+
$this->expectException(DownloadException::class);
31+
$response->setStatusCode(200);
4132
}
4233

4334
public function testSetDateRemembersDateInUTC()

0 commit comments

Comments
 (0)