Skip to content

Commit

Permalink
Improve BaseTestCase::assertImageSize()
Browse files Browse the repository at this point in the history
  • Loading branch information
olivervogel committed Dec 31, 2024
1 parent 52aae98 commit 5b9282e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tests/BaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,12 @@ protected function assertTransparency(ColorInterface $color): void
protected function assertImageSize(string|EncodedImage $image, int $width, int $height): void
{
$info = getimagesizefromstring((string) $image);
$this->assertEquals($info[0], $width, 'Failed asserting that image has width of ' . $width . ' pixels.');
$this->assertEquals($info[1], $height, 'Failed asserting that image has height of ' . $height . ' pixels.');

if (!is_array($info)) {
$this->fail('Failed asserting that image has size of ' . $width . ' x ' . $height . ' pixels.');
} else {
$this->assertEquals($info[0], $width, 'Failed asserting that image has width of ' . $width . ' pixels.');
$this->assertEquals($info[1], $height, 'Failed asserting that image has height of ' . $height . ' pixels.');
}
}
}

0 comments on commit 5b9282e

Please sign in to comment.