From c997c0320f63ba25ad679de341824db3c306fde5 Mon Sep 17 00:00:00 2001 From: Mathieu Dubois Date: Wed, 2 Oct 2024 01:13:29 +0200 Subject: [PATCH 1/2] Port test suite to PHPUnitPolyFill --- composer.json | 2 +- package.xml | 1 - tests/AllTests.php | 27 --------------------------- tests/ColorTest.php | 18 ++++++++++++------ 4 files changed, 13 insertions(+), 35 deletions(-) delete mode 100644 tests/AllTests.php diff --git a/composer.json b/composer.json index 36c3e2b..2fbdcd5 100644 --- a/composer.json +++ b/composer.json @@ -33,6 +33,6 @@ }, "type": "library", "require-dev": { - "phpunit/phpunit": "*" + "yoast/phpunit-polyfills": "^2.0" } } diff --git a/package.xml b/package.xml index 039c626..acb8939 100644 --- a/package.xml +++ b/package.xml @@ -39,7 +39,6 @@ Add to Packagist - diff --git a/tests/AllTests.php b/tests/AllTests.php deleted file mode 100644 index 80d8f27..0000000 --- a/tests/AllTests.php +++ /dev/null @@ -1,27 +0,0 @@ -addTestSuite('ColorTest'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'AllTests::main') { - AllTests::main(); -} - -?> diff --git a/tests/ColorTest.php b/tests/ColorTest.php index 8f6b1df..b22b8f0 100644 --- a/tests/ColorTest.php +++ b/tests/ColorTest.php @@ -7,17 +7,23 @@ * @copyright 2005 */ -require_once 'PHPUnit/Framework/TestCase.php'; +// As we want to run on PHP < 7.1, +// we can't use return type declaration in fixtures. +// Therefore we use PHPUnitPolyFills snakecase fixtures set_up/tear_down +// instead of setUp/tearDown. +// See https://github.com/Yoast/PHPUnit-Polyfills?tab=readme-ov-file#option-1-yoastphpunitpolyfillstestcasestestcase +use Yoast\PHPUnitPolyfills\TestCases\TestCase; + require_once 'Image/Color.php'; -class ColorTest extends PHPUnit_Framework_TestCase { +class ColorTest extends Yoast\PHPUnitPolyfills\TestCases\TestCase { var $color; - function setUp() { + function set_up() { $this->color = new Image_Color(); } - function tearDown() { + function tear_down() { unset($this->color); } @@ -37,13 +43,13 @@ function testSetWebsafe() { function testGetGetRange_DefaultParam() { $this->color->setColors('#ffffff', '#000000'); $result = $this->color->getRange(); - $this->assertInternalType('array', $result); + $this->assertIsArray($result); $this->assertEquals(2, count($result)); } function testGetGetRange_Param5() { $this->color->setColors('#ffffff', '#000000'); $result = $this->color->getRange(5); - $this->assertInternalType('array', $result); + $this->assertIsArray($result); $this->assertEquals(5, count($result)); } From 033e51be7db7daa708d9d43df23d9a979f8fd51a Mon Sep 17 00:00:00 2001 From: Mathieu Dubois Date: Wed, 2 Oct 2024 01:58:08 +0200 Subject: [PATCH 2/2] Exclude PHP 8 and above as the code is not compatible --- composer.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/composer.json b/composer.json index 2fbdcd5..e652261 100644 --- a/composer.json +++ b/composer.json @@ -32,6 +32,9 @@ "source": "https://github.com/pear/Image_Color" }, "type": "library", + "require" : { + "php": ">=5.6, < 8.0" + }, "require-dev": { "yoast/phpunit-polyfills": "^2.0" }