mirror of
https://github.com/Intervention/image.git
synced 2025-08-22 13:32:56 +02:00
Add tests, improve code
This commit is contained in:
@@ -48,14 +48,14 @@ final class ImageManagerTestImagick extends BaseTestCase
|
||||
$this->assertInstanceOf(ImageManager::class, $manager);
|
||||
}
|
||||
|
||||
public function testCreateImagick(): void
|
||||
public function testCreate(): void
|
||||
{
|
||||
$manager = new ImageManager(Driver::class);
|
||||
$image = $manager->create(5, 4);
|
||||
$this->assertInstanceOf(ImageInterface::class, $image);
|
||||
}
|
||||
|
||||
public function testAnimateImagick(): void
|
||||
public function testAnimate(): void
|
||||
{
|
||||
$manager = new ImageManager(Driver::class);
|
||||
$image = $manager->animate(function ($animation) {
|
||||
@@ -64,42 +64,42 @@ final class ImageManagerTestImagick extends BaseTestCase
|
||||
$this->assertInstanceOf(ImageInterface::class, $image);
|
||||
}
|
||||
|
||||
public function testReadImagick(): void
|
||||
public function testRead(): void
|
||||
{
|
||||
$manager = new ImageManager(Driver::class);
|
||||
$image = $manager->read($this->getTestResourcePath('red.gif'));
|
||||
$this->assertInstanceOf(ImageInterface::class, $image);
|
||||
}
|
||||
|
||||
public function testReadImagickWithDecoderClassname(): void
|
||||
public function testReadWithDecoderClassname(): void
|
||||
{
|
||||
$manager = new ImageManager(Driver::class);
|
||||
$image = $manager->read($this->getTestResourcePath('red.gif'), FilePathImageDecoder::class);
|
||||
$this->assertInstanceOf(ImageInterface::class, $image);
|
||||
}
|
||||
|
||||
public function testReadImagickWithDecoderInstance(): void
|
||||
public function testReadWithDecoderInstance(): void
|
||||
{
|
||||
$manager = new ImageManager(Driver::class);
|
||||
$image = $manager->read($this->getTestResourcePath('red.gif'), new FilePathImageDecoder());
|
||||
$this->assertInstanceOf(ImageInterface::class, $image);
|
||||
}
|
||||
|
||||
public function testReadImagickWithDecoderClassnameArray(): void
|
||||
public function testReadWithDecoderClassnameArray(): void
|
||||
{
|
||||
$manager = new ImageManager(Driver::class);
|
||||
$image = $manager->read($this->getTestResourcePath('red.gif'), [FilePathImageDecoder::class]);
|
||||
$this->assertInstanceOf(ImageInterface::class, $image);
|
||||
}
|
||||
|
||||
public function testReadImagickWithDecoderInstanceArray(): void
|
||||
public function testReadWithDecoderInstanceArray(): void
|
||||
{
|
||||
$manager = new ImageManager(Driver::class);
|
||||
$image = $manager->read($this->getTestResourcePath('red.gif'), [new FilePathImageDecoder()]);
|
||||
$this->assertInstanceOf(ImageInterface::class, $image);
|
||||
}
|
||||
|
||||
public function testReadImagickWithDecoderInstanceArrayMultiple(): void
|
||||
public function testReadWithDecoderInstanceArrayMultiple(): void
|
||||
{
|
||||
$manager = new ImageManager(Driver::class);
|
||||
$image = $manager->read($this->getTestResourcePath('red.gif'), [
|
||||
@@ -109,17 +109,49 @@ final class ImageManagerTestImagick extends BaseTestCase
|
||||
$this->assertInstanceOf(ImageInterface::class, $image);
|
||||
}
|
||||
|
||||
public function testReadImagickWithRotationAdjustment(): void
|
||||
public function testReadWithRotationAdjustment(): void
|
||||
{
|
||||
$manager = new ImageManager(Driver::class);
|
||||
$image = $manager->read($this->getTestResourcePath('orientation.jpg'));
|
||||
$this->assertColor(1, 0, 254, 255, $image->pickColor(3, 3));
|
||||
}
|
||||
|
||||
public function testReadImagickWithoutRotationAdjustment(): void
|
||||
public function testReadWithoutRotationAdjustment(): void
|
||||
{
|
||||
$manager = new ImageManager(Driver::class, autoOrientation: false);
|
||||
$image = $manager->read($this->getTestResourcePath('orientation.jpg'));
|
||||
$this->assertColor(250, 2, 3, 255, $image->pickColor(3, 3));
|
||||
}
|
||||
|
||||
public function testReadAnimation(): void
|
||||
{
|
||||
$manager = new ImageManager(Driver::class);
|
||||
$image = $manager->read($this->getTestResourcePath('animation.gif'));
|
||||
$this->assertTrue($image->isAnimated());
|
||||
}
|
||||
|
||||
public function testReadAnimationDiscarded(): void
|
||||
{
|
||||
$manager = new ImageManager(Driver::class, decodeAnimation: false);
|
||||
$image = $manager->read($this->getTestResourcePath('animation.gif'));
|
||||
$this->assertFalse($image->isAnimated());
|
||||
}
|
||||
|
||||
public function testApplyBlendingColor(): void
|
||||
{
|
||||
$manager = new ImageManager(Driver::class);
|
||||
$image = $manager->read($this->getTestResourcePath('blocks.png'));
|
||||
$result = $image->blendTransparency();
|
||||
$this->assertColor(255, 255, 255, 255, $image->pickColor(530, 0));
|
||||
$this->assertColor(255, 255, 255, 255, $result->pickColor(530, 0));
|
||||
}
|
||||
|
||||
public function testApplyBlendingColorConfigured(): void
|
||||
{
|
||||
$manager = new ImageManager(Driver::class, blendingColor: 'ff5500');
|
||||
$image = $manager->read($this->getTestResourcePath('blocks.png'));
|
||||
$result = $image->blendTransparency();
|
||||
$this->assertColor(255, 85, 0, 255, $image->pickColor(530, 0));
|
||||
$this->assertColor(255, 85, 0, 255, $result->pickColor(530, 0));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user