Skip to content

Commit

Permalink
Add test assertions to validate the correct mime type
Browse files Browse the repository at this point in the history
  • Loading branch information
olivervogel committed Oct 27, 2024
1 parent f712d68 commit b496d1f
Show file tree
Hide file tree
Showing 15 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/Unit/Drivers/Gd/Encoders/AvifEncoderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ public function testEncode(): void
$encoder = new AvifEncoder(10);
$result = $encoder->encode($image);
$this->assertMediaType('image/avif', $result);
$this->assertEquals('image/avif', $result->mimetype());
}
}
1 change: 1 addition & 0 deletions tests/Unit/Drivers/Gd/Encoders/BmpEncoderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ public function testEncode(): void
$encoder = new BmpEncoder();
$result = $encoder->encode($image);
$this->assertMediaType(['image/bmp', 'image/x-ms-bmp'], $result);
$this->assertEquals('image/bmp', $result->mimetype());
}
}
3 changes: 3 additions & 0 deletions tests/Unit/Drivers/Gd/Encoders/GifEncoderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public function testEncode(): void
$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()
);
Expand All @@ -32,6 +33,7 @@ public function testEncodeInterlaced(): void
$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()
);
Expand All @@ -43,6 +45,7 @@ public function testEncodeInterlacedAnimation(): void
$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()
);
Expand Down
2 changes: 2 additions & 0 deletions tests/Unit/Drivers/Gd/Encoders/JpegEncoderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public function testEncode(): void
$encoder = new JpegEncoder(75);
$result = $encoder->encode($image);
$this->assertMediaType('image/jpeg', $result);
$this->assertEquals('image/jpeg', $result->mimetype());
}

public function testEncodeProgressive(): void
Expand All @@ -31,6 +32,7 @@ public function testEncodeProgressive(): void
$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));
}
}
2 changes: 2 additions & 0 deletions tests/Unit/Drivers/Gd/Encoders/PngEncoderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public function testEncode(): void
$encoder = new PngEncoder();
$result = $encoder->encode($image);
$this->assertMediaType('image/png', $result);
$this->assertEquals('image/png', $result->mimetype());
$this->assertFalse($this->isInterlacedPng($result));
}

Expand All @@ -34,6 +35,7 @@ public function testEncodeInterlaced(): void
$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));
}

Expand Down
1 change: 1 addition & 0 deletions tests/Unit/Drivers/Gd/Encoders/WebpEncoderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ public function testEncode(): void
$encoder = new WebpEncoder(75);
$result = $encoder->encode($image);
$this->assertMediaType('image/webp', $result);
$this->assertEquals('image/webp', $result->mimetype());
}
}
1 change: 1 addition & 0 deletions tests/Unit/Drivers/Imagick/Encoders/AvifEncoderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ public function testEncode(): void
$encoder = new AvifEncoder(10);
$result = $encoder->encode($image);
$this->assertMediaType('image/avif', $result);
$this->assertEquals('image/avif', $result->mimetype());
}
}
1 change: 1 addition & 0 deletions tests/Unit/Drivers/Imagick/Encoders/BmpEncoderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ public function testEncode(): void
$encoder = new BmpEncoder();
$result = $encoder->encode($image);
$this->assertMediaType(['image/bmp', 'image/x-ms-bmp'], $result);
$this->assertEquals('image/bmp', $result->mimetype());
}
}
3 changes: 3 additions & 0 deletions tests/Unit/Drivers/Imagick/Encoders/GifEncoderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public function testEncode(): void
$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()
);
Expand All @@ -32,6 +33,7 @@ public function testEncodeInterlaced(): void
$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()
);
Expand All @@ -43,6 +45,7 @@ public function testEncodeInterlacedAnimation(): void
$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()
);
Expand Down
1 change: 1 addition & 0 deletions tests/Unit/Drivers/Imagick/Encoders/HeicEncoderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ public function testEncode(): void
$encoder = new HeicEncoder(75);
$result = $encoder->encode($image);
$this->assertMediaType('image/heic', $result);
$this->assertEquals('image/heic', $result->mimetype());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ public function testEncode(): void
$encoder = new Jpeg2000Encoder(75);
$result = $encoder->encode($image);
$this->assertMediaType('image/jp2', $result);
$this->assertEquals('image/jp2', $result->mimetype());
}
}
2 changes: 2 additions & 0 deletions tests/Unit/Drivers/Imagick/Encoders/JpegEncoderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public function testEncode(): void
$encoder = new JpegEncoder(75);
$result = $encoder->encode($image);
$this->assertMediaType('image/jpeg', $result);
$this->assertEquals('image/jpeg', $result->mimetype());
}

public function testEncodeProgressive(): void
Expand All @@ -31,6 +32,7 @@ public function testEncodeProgressive(): void
$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));
}
}
2 changes: 2 additions & 0 deletions tests/Unit/Drivers/Imagick/Encoders/PngEncoderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public function testEncode(): void
$encoder = new PngEncoder();
$result = $encoder->encode($image);
$this->assertMediaType('image/png', $result);
$this->assertEquals('image/png', $result->mimetype());
$this->assertFalse($this->isInterlacedPng($result));
}

Expand All @@ -34,6 +35,7 @@ public function testEncodeInterlaced(): void
$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));
}

Expand Down
1 change: 1 addition & 0 deletions tests/Unit/Drivers/Imagick/Encoders/TiffEncoderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ public function testEncode(): void
$encoder = new TiffEncoder();
$result = $encoder->encode($image);
$this->assertMediaType('image/tiff', $result);
$this->assertEquals('image/tiff', $result->mimetype());
}
}
1 change: 1 addition & 0 deletions tests/Unit/Drivers/Imagick/Encoders/WebpEncoderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ public function testEncode(): void
$encoder = new WebpEncoder(75);
$result = $encoder->encode($image);
$this->assertMediaType('image/webp', $result);
$this->assertEquals('image/webp', $result->mimetype());
}
}

0 comments on commit b496d1f

Please sign in to comment.