From 5f7b98772a5110cac1c89c23a821bea8c45f58bc Mon Sep 17 00:00:00 2001 From: Oliver Vogel Date: Tue, 16 Jan 2024 16:49:24 +0100 Subject: [PATCH] Fix bitmap detection in tests --- tests/Drivers/Gd/ImageTest.php | 4 ++-- tests/Drivers/Imagick/ImageTest.php | 4 ++-- tests/TestCase.php | 23 +++++++++++++++++++++++ 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/tests/Drivers/Gd/ImageTest.php b/tests/Drivers/Gd/ImageTest.php index 3e6ea116..fc64489c 100644 --- a/tests/Drivers/Gd/ImageTest.php +++ b/tests/Drivers/Gd/ImageTest.php @@ -305,8 +305,8 @@ class ImageTest extends TestCase public function testToBitmap(): void { - $this->assertMediaType('image/x-ms-bmp', (string) $this->image->toBitmap()); - $this->assertMediaType('image/x-ms-bmp', (string) $this->image->toBmp()); + $this->assertMediaTypeBitmap((string) $this->image->toBitmap()); + $this->assertMediaTypeBitmap((string) $this->image->toBmp()); } public function testToAvif(): void diff --git a/tests/Drivers/Imagick/ImageTest.php b/tests/Drivers/Imagick/ImageTest.php index adbabd4e..55a85ca6 100644 --- a/tests/Drivers/Imagick/ImageTest.php +++ b/tests/Drivers/Imagick/ImageTest.php @@ -298,8 +298,8 @@ class ImageTest extends TestCase public function testToBitmap(): void { - $this->assertMediaType('image/x-ms-bmp', (string) $this->image->toBitmap()); - $this->assertMediaType('image/x-ms-bmp', (string) $this->image->toBmp()); + $this->assertMediaTypeBitmap((string) $this->image->toBitmap()); + $this->assertMediaTypeBitmap((string) $this->image->toBmp()); } public function testToAvif(): void diff --git a/tests/TestCase.php b/tests/TestCase.php index b0691110..5bcdaddd 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -44,4 +44,27 @@ abstract class TestCase extends MockeryTestCase $allowed = is_string($allowed) ? [$allowed] : $allowed; $this->assertTrue(in_array($detected, $allowed)); } + + protected function assertMediaTypeBitmap(string $input): void + { + $this->assertMediaType([ + 'image/x-ms-bmp', + 'image/bmp', + 'bmp', + 'ms-bmp', + 'x-bitmap', + 'x-bmp', + 'x-ms-bmp', + 'x-win-bitmap', + 'x-windows-bmp', + 'x-xbitmap', + 'image/ms-bmp', + 'image/x-bitmap', + 'image/x-bmp', + 'image/x-ms-bmp', + 'image/x-win-bitmap', + 'image/x-windows-bmp', + 'image/x-xbitmap', + ], $input); + } }