Skip to content

Commit e050165

Browse files
authored
Merge pull request #2 from duboism/port_tests_to_phpunit_polyfill
Port test suite to PHPUnitPolyFill
2 parents 79925a1 + 033e51b commit e050165

File tree

4 files changed

+16
-35
lines changed

4 files changed

+16
-35
lines changed

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@
3232
"source": "https://github.com/pear/Image_Color"
3333
},
3434
"type": "library",
35+
"require" : {
36+
"php": ">=5.6, < 8.0"
37+
},
3538
"require-dev": {
36-
"phpunit/phpunit": "*"
39+
"yoast/phpunit-polyfills": "^2.0"
3740
}
3841
}

package.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ Add to Packagist
3939
<contents>
4040
<dir baseinstalldir="/" name="/">
4141
<file baseinstalldir="/" md5sum="b585dd216ae0d49b5db73193bb18d1aa" name="/Image/Color.php" role="php" />
42-
<file baseinstalldir="/" md5sum="0b920a78c4d2dfe149046c9f1b39fe78" name="/tests/AllTests.php" role="php" />
4342
<file baseinstalldir="/" md5sum="885cfef95a516203992eb5b55aa6ef76" name="/tests/ColorTest.php" role="php" />
4443
<file baseinstalldir="/" md5sum="77817ffa40058270728fbaf274499748" name="README" role="data" />
4544
</dir>

tests/AllTests.php

Lines changed: 0 additions & 27 deletions
This file was deleted.

tests/ColorTest.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,23 @@
77
* @copyright 2005
88
*/
99

10-
require_once 'PHPUnit/Framework/TestCase.php';
10+
// As we want to run on PHP < 7.1,
11+
// we can't use return type declaration in fixtures.
12+
// Therefore we use PHPUnitPolyFills snakecase fixtures set_up/tear_down
13+
// instead of setUp/tearDown.
14+
// See https://github.com/Yoast/PHPUnit-Polyfills?tab=readme-ov-file#option-1-yoastphpunitpolyfillstestcasestestcase
15+
use Yoast\PHPUnitPolyfills\TestCases\TestCase;
16+
1117
require_once 'Image/Color.php';
1218

13-
class ColorTest extends PHPUnit_Framework_TestCase {
19+
class ColorTest extends Yoast\PHPUnitPolyfills\TestCases\TestCase {
1420
var $color;
1521

1622

17-
function setUp() {
23+
function set_up() {
1824
$this->color = new Image_Color();
1925
}
20-
function tearDown() {
26+
function tear_down() {
2127
unset($this->color);
2228
}
2329

@@ -37,13 +43,13 @@ function testSetWebsafe() {
3743
function testGetGetRange_DefaultParam() {
3844
$this->color->setColors('#ffffff', '#000000');
3945
$result = $this->color->getRange();
40-
$this->assertInternalType('array', $result);
46+
$this->assertIsArray($result);
4147
$this->assertEquals(2, count($result));
4248
}
4349
function testGetGetRange_Param5() {
4450
$this->color->setColors('#ffffff', '#000000');
4551
$result = $this->color->getRange(5);
46-
$this->assertInternalType('array', $result);
52+
$this->assertIsArray($result);
4753
$this->assertEquals(5, count($result));
4854
}
4955

0 commit comments

Comments
 (0)