Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into 4.5
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Mar 5, 2024
2 parents 8b0752a + 67436e3 commit 15ad0a3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 28 deletions.
1 change: 1 addition & 0 deletions system/HTTP/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 7 additions & 1 deletion system/Validation/FileRules.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down
27 changes: 0 additions & 27 deletions tests/system/Test/TestCaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

use CodeIgniter\CLI\CLI;
use CodeIgniter\Events\Events;
use CodeIgniter\HTTP\Response;
use Config\App;
use Tests\Support\Test\TestForReflectionHelper;

/**
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 15ad0a3

Please sign in to comment.