|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace Intervention\Image\Tests\Unit\Drivers\Imagick\Modifiers; |
| 6 | + |
| 7 | +use PHPUnit\Framework\Attributes\CoversClass; |
| 8 | +use PHPUnit\Framework\Attributes\RequiresPhpExtension; |
| 9 | +use Intervention\Image\Modifiers\CoverDownModifier; |
| 10 | +use Intervention\Image\Tests\ImagickTestCase; |
| 11 | + |
| 12 | +#[RequiresPhpExtension('imagick')] |
| 13 | +#[CoversClass(\Intervention\Image\Modifiers\CoverModifier::class)] |
| 14 | +#[CoversClass(\Intervention\Image\Drivers\Imagick\Modifiers\CoverModifier::class)] |
| 15 | +final class CoverDownModifierTest extends ImagickTestCase |
| 16 | +{ |
| 17 | + public function testModify(): void |
| 18 | + { |
| 19 | + $image = $this->readTestImage('blocks.png'); |
| 20 | + $this->assertEquals(640, $image->width()); |
| 21 | + $this->assertEquals(480, $image->height()); |
| 22 | + $image->modify(new CoverDownModifier(100, 100, 'center')); |
| 23 | + $this->assertEquals(100, $image->width()); |
| 24 | + $this->assertEquals(100, $image->height()); |
| 25 | + $this->assertColor(255, 0, 0, 255, $image->pickColor(90, 90)); |
| 26 | + $this->assertColor(0, 255, 0, 255, $image->pickColor(65, 70)); |
| 27 | + $this->assertColor(0, 0, 255, 255, $image->pickColor(70, 52)); |
| 28 | + $this->assertTransparency($image->pickColor(90, 30)); |
| 29 | + } |
| 30 | + |
| 31 | + public function testModifyOddSize(): void |
| 32 | + { |
| 33 | + $image = $this->createTestImage(375, 250); |
| 34 | + $image->modify(new CoverDownModifier(240, 90, 'center')); |
| 35 | + $this->assertEquals(240, $image->width()); |
| 36 | + $this->assertEquals(90, $image->height()); |
| 37 | + } |
| 38 | +} |
0 commit comments