mirror of
https://github.com/Intervention/image.git
synced 2025-02-22 05:12:30 +01:00
136 lines
3.7 KiB
PHP
136 lines
3.7 KiB
PHP
<?php
|
|
|
|
namespace Intervention\Image\Tests\Drivers\Imagick;
|
|
|
|
use Imagick;
|
|
use Intervention\Image\Analyzers\WidthAnalyzer;
|
|
use Intervention\Image\Collection;
|
|
use Intervention\Image\Drivers\Imagick\Core;
|
|
use Intervention\Image\Drivers\Imagick\Driver;
|
|
use Intervention\Image\Drivers\Imagick\Frame;
|
|
use Intervention\Image\EncodedImage;
|
|
use Intervention\Image\Encoders\PngEncoder;
|
|
use Intervention\Image\Exceptions\ColorException;
|
|
use Intervention\Image\Image;
|
|
use Intervention\Image\Interfaces\ColorInterface;
|
|
use Intervention\Image\Interfaces\ColorspaceInterface;
|
|
use Intervention\Image\Interfaces\ResolutionInterface;
|
|
use Intervention\Image\Interfaces\SizeInterface;
|
|
use Intervention\Image\Modifiers\GreyscaleModifier;
|
|
use Intervention\Image\Tests\TestCase;
|
|
|
|
class ImageTest extends TestCase
|
|
{
|
|
protected Image $image;
|
|
|
|
public function setUp(): void
|
|
{
|
|
$imagick = new Imagick();
|
|
$imagick->readImage(__DIR__ . '/../../images/animation.gif');
|
|
$this->image = new Image(
|
|
new Driver(),
|
|
new Core($imagick),
|
|
new Collection([
|
|
'test' => 'foo'
|
|
]),
|
|
);
|
|
}
|
|
|
|
public function testDriver(): void
|
|
{
|
|
$this->assertInstanceOf(Driver::class, $this->image->driver());
|
|
}
|
|
|
|
public function testCore(): void
|
|
{
|
|
$this->assertInstanceOf(Core::class, $this->image->core());
|
|
}
|
|
|
|
public function testCount(): void
|
|
{
|
|
$this->assertEquals(8, $this->image->count());
|
|
}
|
|
|
|
public function testIteration(): void
|
|
{
|
|
foreach ($this->image as $frame) {
|
|
$this->assertInstanceOf(Frame::class, $frame);
|
|
}
|
|
}
|
|
|
|
public function testIsAnimated(): void
|
|
{
|
|
$this->assertTrue($this->image->isAnimated());
|
|
}
|
|
|
|
public function testLoops(): void
|
|
{
|
|
$this->assertEquals(3, $this->image->loops());
|
|
}
|
|
|
|
public function testExif(): void
|
|
{
|
|
$this->assertInstanceOf(Collection::class, $this->image->exif());
|
|
$this->assertEquals('foo', $this->image->exif('test'));
|
|
}
|
|
|
|
public function testModify(): void
|
|
{
|
|
$result = $this->image->modify(new GreyscaleModifier());
|
|
$this->assertInstanceOf(Image::class, $result);
|
|
}
|
|
|
|
public function testAnalyze(): void
|
|
{
|
|
$result = $this->image->analyze(new WidthAnalyzer());
|
|
$this->assertEquals(20, $result);
|
|
}
|
|
|
|
public function testEncode(): void
|
|
{
|
|
$result = $this->image->encode(new PngEncoder());
|
|
$this->assertInstanceOf(EncodedImage::class, $result);
|
|
}
|
|
|
|
public function testWidthHeightSize(): void
|
|
{
|
|
$this->assertEquals(20, $this->image->width());
|
|
$this->assertEquals(15, $this->image->height());
|
|
$this->assertInstanceOf(SizeInterface::class, $this->image->size());
|
|
}
|
|
|
|
public function testColorspace(): void
|
|
{
|
|
$this->assertInstanceOf(ColorspaceInterface::class, $this->image->colorspace());
|
|
}
|
|
|
|
public function testResolution(): void
|
|
{
|
|
$this->assertInstanceOf(ResolutionInterface::class, $this->image->resolution());
|
|
}
|
|
|
|
public function testPickColor(): void
|
|
{
|
|
$this->assertInstanceOf(ColorInterface::class, $this->image->pickColor(0, 0));
|
|
$this->assertInstanceOf(ColorInterface::class, $this->image->pickColor(0, 0, 1));
|
|
}
|
|
|
|
public function testPickColors(): void
|
|
{
|
|
$result = $this->image->pickColors(0, 0);
|
|
$this->assertInstanceOf(Collection::class, $result);
|
|
$this->assertEquals(8, $result->count());
|
|
}
|
|
|
|
public function testProfile(): void
|
|
{
|
|
$this->expectException(ColorException::class);
|
|
$this->image->profile();
|
|
}
|
|
|
|
public function testSharpen(): void
|
|
{
|
|
$this->assertInstanceOf(Image::class, $this->image->sharpen(12));
|
|
}
|
|
}
|