Skip to content

Commit

Permalink
Improve error messages of BaseTestCase::assertImageSize()
Browse files Browse the repository at this point in the history
  • Loading branch information
olivervogel committed Dec 31, 2024
1 parent 5b9282e commit 9b9465d
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions tests/BaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,18 @@ protected function assertImageSize(string|EncodedImage $image, int $width, int $
$info = getimagesizefromstring((string) $image);

if (!is_array($info)) {
$this->fail('Failed asserting that image has size of ' . $width . ' x ' . $height . ' pixels.');
$this->fail('Unable to read image size.');
} 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.');
$this->assertEquals(
(int) $info[0],
$width,
'Failed asserting that the detected image width (' . $info[0] . ') is ' . $width . ' pixels.',
);
$this->assertEquals(
(int) $info[1],
$height,
'Failed asserting that the detected image height (' . $info[1] . ') is ' . $height . ' pixels.',
);
}
}
}

0 comments on commit 9b9465d

Please sign in to comment.