mirror of
https://github.com/Intervention/image.git
synced 2025-08-23 22:12:51 +02:00
PHPUnit 10 Migration (#1302)
* Bump PHPUnit dependencies * Set return type of base TestCase methods From the [PHPUnit 8 release notes][1], the `TestCase` methods below now declare a `void` return type: - `setUpBeforeClass()` - `setUp()` - `assertPreConditions()` - `assertPostConditions()` - `tearDown()` - `tearDownAfterClass()` - `onNotSuccessfulTest()` [1]: https://phpunit.de/announcements/phpunit-8.html * Ignore PHPUnit cache folder * Adopt PHP attributes in test classes * Declare data providers as `static` * Add return types to test methods * Define test classes as `final` * Migrate phpunit.xml to phpunit 10 * Correct phpunit attribute class name * Rename base test class * Restructure test folders * Fix test image paths * Only set rules for php files in .editorconfig * Remove php unit flag in local test env --------- Co-authored-by: Shift <shift@laravelshift.com>
This commit is contained in:
84
tests/Unit/Drivers/Imagick/DriverTest.php
Normal file
84
tests/Unit/Drivers/Imagick/DriverTest.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Intervention\Image\Tests\Unit\Drivers\Imagick;
|
||||
|
||||
use Intervention\Image\Colors\Rgb\Colorspace;
|
||||
use Intervention\Image\Colors\Rgb\Decoders\HexColorDecoder;
|
||||
use Intervention\Image\Drivers\Imagick\Driver;
|
||||
use Intervention\Image\Interfaces\ColorInterface;
|
||||
use Intervention\Image\Interfaces\ColorProcessorInterface;
|
||||
use Intervention\Image\Interfaces\ImageInterface;
|
||||
use Intervention\Image\Tests\BaseTestCase;
|
||||
|
||||
final class DriverTest extends BaseTestCase
|
||||
{
|
||||
protected Driver $driver;
|
||||
|
||||
protected 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());
|
||||
}
|
||||
|
||||
public function testHandleInputImage(): void
|
||||
{
|
||||
$result = $this->driver->handleInput($this->getTestImagePath('test.jpg'));
|
||||
$this->assertInstanceOf(ImageInterface::class, $result);
|
||||
}
|
||||
|
||||
public function testHandleInputColor(): void
|
||||
{
|
||||
$result = $this->driver->handleInput('ffffff');
|
||||
$this->assertInstanceOf(ColorInterface::class, $result);
|
||||
}
|
||||
|
||||
public function testHandleInputObjects(): void
|
||||
{
|
||||
$result = $this->driver->handleInput('ffffff', [
|
||||
new HexColorDecoder()
|
||||
]);
|
||||
$this->assertInstanceOf(ColorInterface::class, $result);
|
||||
}
|
||||
|
||||
public function testHandleInputClassnames(): void
|
||||
{
|
||||
$result = $this->driver->handleInput('ffffff', [
|
||||
HexColorDecoder::class
|
||||
]);
|
||||
$this->assertInstanceOf(ColorInterface::class, $result);
|
||||
}
|
||||
|
||||
public function testColorProcessor(): void
|
||||
{
|
||||
$result = $this->driver->colorProcessor(new Colorspace());
|
||||
$this->assertInstanceOf(ColorProcessorInterface::class, $result);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user