diff --git a/system/HTTP/Response.php b/system/HTTP/Response.php index 8c935225ae46..a19fbb5fee14 100644 --- a/system/HTTP/Response.php +++ b/system/HTTP/Response.php @@ -178,6 +178,7 @@ public function __construct($config) // @phpstan-ignore-line * * @return $this * + * @internal For testing purposes only. * @testTag only available to test code */ public function pretend(bool $pretend = true) diff --git a/system/Validation/FileRules.php b/system/Validation/FileRules.php index a36e31872a36..022b19361615 100644 --- a/system/Validation/FileRules.php +++ b/system/Validation/FileRules.php @@ -244,7 +244,13 @@ public function max_dims(?string $blank, string $params): bool $allowedHeight = $params[1] ?? 0; // Get uploaded image size - $info = getimagesize($file->getTempName()); + $info = getimagesize($file->getTempName()); + + if ($info === false) { + // Cannot get the image size. + return false; + } + $fileWidth = $info[0]; $fileHeight = $info[1]; diff --git a/tests/system/Test/TestCaseTest.php b/tests/system/Test/TestCaseTest.php index 274debc73bd9..6521029636d3 100644 --- a/tests/system/Test/TestCaseTest.php +++ b/tests/system/Test/TestCaseTest.php @@ -15,8 +15,6 @@ use CodeIgniter\CLI\CLI; use CodeIgniter\Events\Events; -use CodeIgniter\HTTP\Response; -use Config\App; use Tests\Support\Test\TestForReflectionHelper; /** @@ -76,31 +74,6 @@ public function testStreamFilter(): void $this->assertSame($expected, $this->getStreamFilterBuffer()); } - /** - * PHPunit emits headers before we get nominal control of - * the output stream, making header testing awkward, to say - * the least. This test is intended to make sure that this - * is happening as expected. - * - * TestCaseEmissionsTest is intended to circumvent PHPunit, - * and allow us to test our own header emissions. - */ - public function testPHPUnitHeadersEmitted(): void - { - $response = new Response(new App()); - $response->pretend(true); - - $body = 'Hello'; - $response->setBody($body); - - ob_start(); - $response->send(); - ob_end_clean(); - - $this->assertHeaderEmitted('Content-type: text/html;'); - $this->assertHeaderNotEmitted('Set-Cookie: foo=bar;'); - } - public function testCloseEnough(): void { $this->assertCloseEnough(1, 1);