1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-26 15:24:37 +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,71 @@
<?php
declare(strict_types=1);
namespace Intervention\Image\Tests\Unit\Drivers\Gd;
use Intervention\Image\Colors\Rgb\Color;
use Intervention\Image\Drivers\Gd\Cloner;
use Intervention\Image\Geometry\Rectangle;
use Intervention\Image\Tests\BaseTestCase;
final class ClonerTest extends BaseTestCase
{
public function testClone(): void
{
$gd = imagecreatefromgif($this->getTestImagePath('gradient.gif'));
$clone = Cloner::clone($gd);
$this->assertEquals(16, imagesx($gd));
$this->assertEquals(16, imagesy($gd));
$this->assertEquals(16, imagesx($clone));
$this->assertEquals(16, imagesy($clone));
$this->assertEquals(
imagecolorsforindex($gd, imagecolorat($gd, 10, 10)),
imagecolorsforindex($clone, imagecolorat($clone, 10, 10))
);
}
public function testCloneEmpty(): void
{
$gd = imagecreatefromgif($this->getTestImagePath('gradient.gif'));
$clone = Cloner::cloneEmpty($gd, new Rectangle(12, 12), new Color(255, 0, 0, 0));
$this->assertEquals(16, imagesx($gd));
$this->assertEquals(16, imagesy($gd));
$this->assertEquals(12, imagesx($clone));
$this->assertEquals(12, imagesy($clone));
$this->assertEquals(
['red' => 0, 'green' => 255, 'blue' => 2, 'alpha' => 0],
imagecolorsforindex($gd, imagecolorat($gd, 10, 10)),
);
$this->assertEquals(
['red' => 255, 'green' => 0, 'blue' => 0, 'alpha' => 127],
imagecolorsforindex($clone, imagecolorat($clone, 10, 10))
);
}
public function testCLoneBlended(): void
{
$gd = imagecreatefromgif($this->getTestImagePath('gradient.gif'));
$clone = Cloner::cloneBlended($gd, new Color(255, 0, 255, 255));
$this->assertEquals(16, imagesx($gd));
$this->assertEquals(16, imagesy($gd));
$this->assertEquals(16, imagesx($clone));
$this->assertEquals(16, imagesy($clone));
$this->assertEquals(
['red' => 0, 'green' => 0, 'blue' => 0, 'alpha' => 127],
imagecolorsforindex($gd, imagecolorat($gd, 1, 0)),
);
$this->assertEquals(
['red' => 255, 'green' => 0, 'blue' => 255, 'alpha' => 0],
imagecolorsforindex($clone, imagecolorat($clone, 1, 0))
);
}
}