1
0
mirror of https://github.com/Intervention/image.git synced 2025-01-16 19:58:14 +01:00

Add test assertions to validate the correct mime type

This commit is contained in:
Oliver Vogel 2024-10-27 11:15:54 +01:00
parent f712d684db
commit b496d1f6b9
No known key found for this signature in database
GPG Key ID: 1B19D214C02D69BB
15 changed files with 23 additions and 0 deletions

View File

@ -20,5 +20,6 @@ final class AvifEncoderTest extends GdTestCase
$encoder = new AvifEncoder(10);
$result = $encoder->encode($image);
$this->assertMediaType('image/avif', $result);
$this->assertEquals('image/avif', $result->mimetype());
}
}

View File

@ -20,5 +20,6 @@ final class BmpEncoderTest extends GdTestCase
$encoder = new BmpEncoder();
$result = $encoder->encode($image);
$this->assertMediaType(['image/bmp', 'image/x-ms-bmp'], $result);
$this->assertEquals('image/bmp', $result->mimetype());
}
}

View File

@ -21,6 +21,7 @@ final class GifEncoderTest extends GdTestCase
$encoder = new GifEncoder();
$result = $encoder->encode($image);
$this->assertMediaType('image/gif', $result);
$this->assertEquals('image/gif', $result->mimetype());
$this->assertFalse(
Decoder::decode((string) $result)->getFirstFrame()->getImageDescriptor()->isInterlaced()
);
@ -32,6 +33,7 @@ final class GifEncoderTest extends GdTestCase
$encoder = new GifEncoder(interlaced: true);
$result = $encoder->encode($image);
$this->assertMediaType('image/gif', $result);
$this->assertEquals('image/gif', $result->mimetype());
$this->assertTrue(
Decoder::decode((string) $result)->getFirstFrame()->getImageDescriptor()->isInterlaced()
);
@ -43,6 +45,7 @@ final class GifEncoderTest extends GdTestCase
$encoder = new GifEncoder(interlaced: true);
$result = $encoder->encode($image);
$this->assertMediaType('image/gif', $result);
$this->assertEquals('image/gif', $result->mimetype());
$this->assertTrue(
Decoder::decode((string) $result)->getFirstFrame()->getImageDescriptor()->isInterlaced()
);

View File

@ -23,6 +23,7 @@ final class JpegEncoderTest extends GdTestCase
$encoder = new JpegEncoder(75);
$result = $encoder->encode($image);
$this->assertMediaType('image/jpeg', $result);
$this->assertEquals('image/jpeg', $result->mimetype());
}
public function testEncodeProgressive(): void
@ -31,6 +32,7 @@ final class JpegEncoderTest extends GdTestCase
$encoder = new JpegEncoder(progressive: true);
$result = $encoder->encode($image);
$this->assertMediaType('image/jpeg', $result);
$this->assertEquals('image/jpeg', $result->mimetype());
$this->assertTrue($this->isProgressiveJpeg($result));
}
}

View File

@ -25,6 +25,7 @@ final class PngEncoderTest extends GdTestCase
$encoder = new PngEncoder();
$result = $encoder->encode($image);
$this->assertMediaType('image/png', $result);
$this->assertEquals('image/png', $result->mimetype());
$this->assertFalse($this->isInterlacedPng($result));
}
@ -34,6 +35,7 @@ final class PngEncoderTest extends GdTestCase
$encoder = new PngEncoder(interlaced: true);
$result = $encoder->encode($image);
$this->assertMediaType('image/png', $result);
$this->assertEquals('image/png', $result->mimetype());
$this->assertTrue($this->isInterlacedPng($result));
}

View File

@ -20,5 +20,6 @@ final class WebpEncoderTest extends GdTestCase
$encoder = new WebpEncoder(75);
$result = $encoder->encode($image);
$this->assertMediaType('image/webp', $result);
$this->assertEquals('image/webp', $result->mimetype());
}
}

View File

@ -20,5 +20,6 @@ final class AvifEncoderTest extends ImagickTestCase
$encoder = new AvifEncoder(10);
$result = $encoder->encode($image);
$this->assertMediaType('image/avif', $result);
$this->assertEquals('image/avif', $result->mimetype());
}
}

View File

@ -20,5 +20,6 @@ final class BmpEncoderTest extends ImagickTestCase
$encoder = new BmpEncoder();
$result = $encoder->encode($image);
$this->assertMediaType(['image/bmp', 'image/x-ms-bmp'], $result);
$this->assertEquals('image/bmp', $result->mimetype());
}
}

View File

@ -21,6 +21,7 @@ final class GifEncoderTest extends ImagickTestCase
$encoder = new GifEncoder();
$result = $encoder->encode($image);
$this->assertMediaType('image/gif', $result);
$this->assertEquals('image/gif', $result->mimetype());
$this->assertFalse(
Decoder::decode((string) $result)->getFirstFrame()->getImageDescriptor()->isInterlaced()
);
@ -32,6 +33,7 @@ final class GifEncoderTest extends ImagickTestCase
$encoder = new GifEncoder(interlaced: true);
$result = $encoder->encode($image);
$this->assertMediaType('image/gif', $result);
$this->assertEquals('image/gif', $result->mimetype());
$this->assertTrue(
Decoder::decode((string) $result)->getFirstFrame()->getImageDescriptor()->isInterlaced()
);
@ -43,6 +45,7 @@ final class GifEncoderTest extends ImagickTestCase
$encoder = new GifEncoder(interlaced: true);
$result = $encoder->encode($image);
$this->assertMediaType('image/gif', $result);
$this->assertEquals('image/gif', $result->mimetype());
$this->assertTrue(
Decoder::decode((string) $result)->getFirstFrame()->getImageDescriptor()->isInterlaced()
);

View File

@ -20,5 +20,6 @@ final class HeicEncoderTest extends ImagickTestCase
$encoder = new HeicEncoder(75);
$result = $encoder->encode($image);
$this->assertMediaType('image/heic', $result);
$this->assertEquals('image/heic', $result->mimetype());
}
}

View File

@ -20,5 +20,6 @@ final class Jpeg2000EncoderTest extends ImagickTestCase
$encoder = new Jpeg2000Encoder(75);
$result = $encoder->encode($image);
$this->assertMediaType('image/jp2', $result);
$this->assertEquals('image/jp2', $result->mimetype());
}
}

View File

@ -23,6 +23,7 @@ final class JpegEncoderTest extends ImagickTestCase
$encoder = new JpegEncoder(75);
$result = $encoder->encode($image);
$this->assertMediaType('image/jpeg', $result);
$this->assertEquals('image/jpeg', $result->mimetype());
}
public function testEncodeProgressive(): void
@ -31,6 +32,7 @@ final class JpegEncoderTest extends ImagickTestCase
$encoder = new JpegEncoder(progressive: true);
$result = $encoder->encode($image);
$this->assertMediaType('image/jpeg', $result);
$this->assertEquals('image/jpeg', $result->mimetype());
$this->assertTrue($this->isProgressiveJpeg($result));
}
}

View File

@ -25,6 +25,7 @@ final class PngEncoderTest extends ImagickTestCase
$encoder = new PngEncoder();
$result = $encoder->encode($image);
$this->assertMediaType('image/png', $result);
$this->assertEquals('image/png', $result->mimetype());
$this->assertFalse($this->isInterlacedPng($result));
}
@ -34,6 +35,7 @@ final class PngEncoderTest extends ImagickTestCase
$encoder = new PngEncoder(interlaced: true);
$result = $encoder->encode($image);
$this->assertMediaType('image/png', $result);
$this->assertEquals('image/png', $result->mimetype());
$this->assertTrue($this->isInterlacedPng($result));
}

View File

@ -20,5 +20,6 @@ final class TiffEncoderTest extends ImagickTestCase
$encoder = new TiffEncoder();
$result = $encoder->encode($image);
$this->assertMediaType('image/tiff', $result);
$this->assertEquals('image/tiff', $result->mimetype());
}
}

View File

@ -20,5 +20,6 @@ final class WebpEncoderTest extends ImagickTestCase
$encoder = new WebpEncoder(75);
$result = $encoder->encode($image);
$this->assertMediaType('image/webp', $result);
$this->assertEquals('image/webp', $result->mimetype());
}
}