mirror of
https://github.com/Intervention/image.git
synced 2025-08-27 07:44:30 +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:
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Intervention\Image\Tests\Unit\Drivers\Imagick\Decoders;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
|
||||
use Intervention\Image\Drivers\Imagick\Decoders\FilePathImageDecoder;
|
||||
use Intervention\Image\Exceptions\DecoderException;
|
||||
use Intervention\Image\Image;
|
||||
use Intervention\Image\Tests\BaseTestCase;
|
||||
use stdClass;
|
||||
|
||||
#[RequiresPhpExtension('imagick')]
|
||||
#[CoversClass(\Intervention\Image\Drivers\Imagick\Decoders\FilePathImageDecoder::class)]
|
||||
final class FilePathImageDecoderTest extends BaseTestCase
|
||||
{
|
||||
protected FilePathImageDecoder $decoder;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->decoder = new FilePathImageDecoder();
|
||||
}
|
||||
|
||||
public function testDecode(): void
|
||||
{
|
||||
$result = $this->decoder->decode(
|
||||
$this->getTestImagePath()
|
||||
);
|
||||
|
||||
$this->assertInstanceOf(Image::class, $result);
|
||||
}
|
||||
|
||||
public function testDecoderNonString(): void
|
||||
{
|
||||
$this->expectException(DecoderException::class);
|
||||
$this->decoder->decode(new stdClass());
|
||||
}
|
||||
|
||||
public function testDecoderNoPath(): void
|
||||
{
|
||||
$this->expectException(DecoderException::class);
|
||||
$this->decoder->decode('no-path');
|
||||
}
|
||||
|
||||
public function testDecoderTooLongPath(): void
|
||||
{
|
||||
$this->expectException(DecoderException::class);
|
||||
$this->decoder->decode(str_repeat('x', PHP_MAXPATHLEN + 1));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user