Skip to content

Commit ddbf6d3

Browse files
committed
fix: change exception RuntimeException -> LogicException.
Signed-off-by: ytetsuro <phper.0o0@gmail.com>
1 parent 5f513b8 commit ddbf6d3

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

system/HTTP/DownloadResponse.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
*/
3838
use CodeIgniter\HTTP\Exceptions\HTTPException;
3939
use BadMethodCallException;
40+
use LogicException;
4041
use CodeIgniter\Files\File;
4142
use Config\Mimes;
4243

@@ -488,7 +489,7 @@ public function sendBody()
488489
return $this->sendBodyByFilePath();
489490
}
490491

491-
throw new RuntimeException();
492+
throw new LogicException('Not found download body source.');
492493
}
493494

494495
/**

tests/system/HTTP/DownloadResponseTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use DateTimeZone;
77
use BadMethodCallException;
88
use InvalidArgumentException;
9+
use LogicException;
910

1011
class DownloadResponseTest extends \CIUnitTestCase
1112
{
@@ -242,4 +243,12 @@ public function testCanOutputFileBodyFromFile()
242243

243244
$this->assertSame(file_get_contents(__FILE__), $actual);
244245
}
246+
247+
public function testThrowExceptionWhenNoSetDownloadSource()
248+
{
249+
$response = new DownloadResponse('unit-test.php', false);
250+
251+
$this->expectException(LogicException::class);
252+
$response->sendBody();
253+
}
245254
}

0 commit comments

Comments
 (0)