1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-01 11:30:16 +02:00

Add tests

This commit is contained in:
Oliver Vogel
2024-01-15 20:23:09 +01:00
parent 92135d9889
commit 4338e00dcd
4 changed files with 90 additions and 0 deletions

View File

@@ -27,6 +27,7 @@ class Driver extends AbstractDriver
* {@inheritdoc}
*
* @see DriverInterface::checkHealth()
* @codeCoverageIgnore
*/
public function checkHealth(): void
{

View File

@@ -29,6 +29,7 @@ class Driver extends AbstractDriver
* {@inheritdoc}
*
* @see DriverInterface::checkHealth()
* @codeCoverageIgnore
*/
public function checkHealth(): void
{

View File

@@ -0,0 +1,44 @@
<?php
namespace Intervention\Image\Tests\Drivers\Gd;
use Intervention\Image\Drivers\Gd\Driver;
use Intervention\Image\Interfaces\ImageInterface;
use Intervention\Image\Tests\TestCase;
class DriverTest extends TestCase
{
protected Driver $driver;
public function setUp(): void
{
$this->driver = new Driver();
}
public function testId(): void
{
$this->assertEquals('GD', $this->driver->id());
}
public function testCreateImage(): void
{
$image = $this->driver->createImage(3, 2);
$this->assertInstanceOf(ImageInterface::class, $image);
$this->assertEquals(3, $image->width());
$this->assertEquals(2, $image->height());
}
public function testCreateAnimation(): void
{
$image = $this->driver->createAnimation(function ($animation) {
$animation->add($this->getTestImagePath('red.gif'), .25);
$animation->add($this->getTestImagePath('green.gif'), .25);
})->setLoops(5);
$this->assertInstanceOf(ImageInterface::class, $image);
$this->assertEquals(16, $image->width());
$this->assertEquals(16, $image->height());
$this->assertEquals(5, $image->loops());
$this->assertEquals(2, $image->count());
}
}

View File

@@ -0,0 +1,44 @@
<?php
namespace Intervention\Image\Tests\Drivers\Imagick;
use Intervention\Image\Drivers\Imagick\Driver;
use Intervention\Image\Interfaces\ImageInterface;
use Intervention\Image\Tests\TestCase;
class DriverTest extends TestCase
{
protected Driver $driver;
public function setUp(): void
{
$this->driver = new Driver();
}
public function testId(): void
{
$this->assertEquals('Imagick', $this->driver->id());
}
public function testCreateImage(): void
{
$image = $this->driver->createImage(3, 2);
$this->assertInstanceOf(ImageInterface::class, $image);
$this->assertEquals(3, $image->width());
$this->assertEquals(2, $image->height());
}
public function testCreateAnimation(): void
{
$image = $this->driver->createAnimation(function ($animation) {
$animation->add($this->getTestImagePath('red.gif'), .25);
$animation->add($this->getTestImagePath('green.gif'), .25);
})->setLoops(5);
$this->assertInstanceOf(ImageInterface::class, $image);
$this->assertEquals(16, $image->width());
$this->assertEquals(16, $image->height());
$this->assertEquals(5, $image->loops());
$this->assertEquals(2, $image->count());
}
}