1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-26 07:14:31 +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:
Oliver Vogel
2024-02-28 16:16:23 +01:00
committed by GitHub
parent fe1b0e2e64
commit dcc95b8299
183 changed files with 1347 additions and 1392 deletions

View File

@@ -0,0 +1,57 @@
<?php
declare(strict_types=1);
namespace Intervention\Image\Tests\Unit\Drivers\Gd\Decoders;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
use Intervention\Image\Drivers\Gd\Decoders\BinaryImageDecoder;
use Intervention\Image\Image;
use Intervention\Image\Tests\BaseTestCase;
#[RequiresPhpExtension('gd')]
#[CoversClass(\Intervention\Image\Drivers\Gd\Decoders\BinaryImageDecoder::class)]
final class BinaryImageDecoderTest extends BaseTestCase
{
public function testDecodePng(): void
{
$decoder = new BinaryImageDecoder();
$image = $decoder->decode(file_get_contents($this->getTestImagePath('tile.png')));
$this->assertInstanceOf(Image::class, $image);
$this->assertEquals(16, $image->width());
$this->assertEquals(16, $image->height());
$this->assertCount(1, $image);
}
public function testDecodeGif(): void
{
$decoder = new BinaryImageDecoder();
$image = $decoder->decode(file_get_contents($this->getTestImagePath('red.gif')));
$this->assertInstanceOf(Image::class, $image);
$this->assertEquals(16, $image->width());
$this->assertEquals(16, $image->height());
$this->assertCount(1, $image);
}
public function testDecodeAnimatedGif(): void
{
$decoder = new BinaryImageDecoder();
$image = $decoder->decode(file_get_contents($this->getTestImagePath('cats.gif')));
$this->assertInstanceOf(Image::class, $image);
$this->assertEquals(75, $image->width());
$this->assertEquals(50, $image->height());
$this->assertCount(4, $image);
}
public function testDecodeJpegWithExif(): void
{
$decoder = new BinaryImageDecoder();
$image = $decoder->decode(file_get_contents($this->getTestImagePath('exif.jpg')));
$this->assertInstanceOf(Image::class, $image);
$this->assertEquals(16, $image->width());
$this->assertEquals(16, $image->height());
$this->assertCount(1, $image);
$this->assertEquals('Oliver Vogel', $image->exif('IFD0.Artist'));
}
}