mirror of
https://github.com/Intervention/image.git
synced 2025-08-29 08:40:33 +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:
30
tests/Unit/Modifiers/ColorspaceModifierTest.php
Normal file
30
tests/Unit/Modifiers/ColorspaceModifierTest.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Intervention\Image\Tests\Unit\Modifiers;
|
||||
|
||||
use Intervention\Image\Colors\Rgb\Colorspace;
|
||||
use Intervention\Image\Exceptions\NotSupportedException;
|
||||
use Intervention\Image\Interfaces\ColorspaceInterface;
|
||||
use Intervention\Image\Modifiers\ColorspaceModifier;
|
||||
use Intervention\Image\Tests\BaseTestCase;
|
||||
|
||||
final class ColorspaceModifierTest extends BaseTestCase
|
||||
{
|
||||
public function testTargetColorspace(): void
|
||||
{
|
||||
$modifier = new ColorspaceModifier(new Colorspace());
|
||||
$this->assertInstanceOf(ColorspaceInterface::class, $modifier->targetColorspace());
|
||||
|
||||
$modifier = new ColorspaceModifier('rgb');
|
||||
$this->assertInstanceOf(ColorspaceInterface::class, $modifier->targetColorspace());
|
||||
|
||||
$modifier = new ColorspaceModifier('cmyk');
|
||||
$this->assertInstanceOf(ColorspaceInterface::class, $modifier->targetColorspace());
|
||||
|
||||
$modifier = new ColorspaceModifier('test');
|
||||
$this->expectException(NotSupportedException::class);
|
||||
$modifier->targetColorspace();
|
||||
}
|
||||
}
|
24
tests/Unit/Modifiers/PadModifierTest.php
Normal file
24
tests/Unit/Modifiers/PadModifierTest.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Intervention\Image\Tests\Unit\Modifiers;
|
||||
|
||||
use Intervention\Image\Geometry\Rectangle;
|
||||
use Intervention\Image\Interfaces\ImageInterface;
|
||||
use Intervention\Image\Interfaces\SizeInterface;
|
||||
use Intervention\Image\Modifiers\PadModifier;
|
||||
use Intervention\Image\Tests\BaseTestCase;
|
||||
use Mockery;
|
||||
|
||||
final class PadModifierTest extends BaseTestCase
|
||||
{
|
||||
public function testGetCropSize(): void
|
||||
{
|
||||
$modifier = new PadModifier(300, 200);
|
||||
$image = Mockery::mock(ImageInterface::class);
|
||||
$size = new Rectangle(300, 200);
|
||||
$image->shouldReceive('size')->andReturn($size);
|
||||
$this->assertInstanceOf(SizeInterface::class, $modifier->getCropSize($image));
|
||||
}
|
||||
}
|
23
tests/Unit/Modifiers/SpecializableModifierTest.php
Normal file
23
tests/Unit/Modifiers/SpecializableModifierTest.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Intervention\Image\Tests\Unit\Modifiers;
|
||||
|
||||
use Intervention\Image\Modifiers\SpecializableModifier;
|
||||
use Intervention\Image\Interfaces\ImageInterface;
|
||||
use Intervention\Image\Tests\BaseTestCase;
|
||||
use Mockery;
|
||||
|
||||
final class SpecializableModifierTest extends BaseTestCase
|
||||
{
|
||||
public function testApply(): void
|
||||
{
|
||||
$modifier = Mockery::mock(SpecializableModifier::class)->makePartial();
|
||||
$image = Mockery::mock(ImageInterface::class);
|
||||
$image->shouldReceive('modify')->andReturn($image);
|
||||
|
||||
$result = $modifier->apply($image);
|
||||
$this->assertInstanceOf(ImageInterface::class, $result);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user