Skip to content

Commit

Permalink
Merge pull request #2 from duboism/port_tests_to_phpunit_polyfill
Browse files Browse the repository at this point in the history
Port test suite to PHPUnitPolyFill
  • Loading branch information
ashnazg authored Nov 24, 2024
2 parents 79925a1 + 033e51b commit e050165
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 35 deletions.
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@
"source": "https://github.com/pear/Image_Color"
},
"type": "library",
"require" : {
"php": ">=5.6, < 8.0"
},
"require-dev": {
"phpunit/phpunit": "*"
"yoast/phpunit-polyfills": "^2.0"
}
}
1 change: 0 additions & 1 deletion package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ Add to Packagist
<contents>
<dir baseinstalldir="/" name="/">
<file baseinstalldir="/" md5sum="b585dd216ae0d49b5db73193bb18d1aa" name="/Image/Color.php" role="php" />
<file baseinstalldir="/" md5sum="0b920a78c4d2dfe149046c9f1b39fe78" name="/tests/AllTests.php" role="php" />
<file baseinstalldir="/" md5sum="885cfef95a516203992eb5b55aa6ef76" name="/tests/ColorTest.php" role="php" />
<file baseinstalldir="/" md5sum="77817ffa40058270728fbaf274499748" name="README" role="data" />
</dir>
Expand Down
27 changes: 0 additions & 27 deletions tests/AllTests.php

This file was deleted.

18 changes: 12 additions & 6 deletions tests/ColorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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));
}

Expand Down

0 comments on commit e050165

Please sign in to comment.