From 51d8b4402a1d2401d363fcec19bce229e30f4d59 Mon Sep 17 00:00:00 2001 From: Simon Frings Date: Thu, 29 Jul 2021 11:42:59 +0200 Subject: [PATCH 1/2] Run tests on PHPUnit 9 --- .gitattributes | 1 + .github/workflows/ci.yml | 3 +++ composer.json | 2 +- phpunit.xml.dist | 15 ++++++++++----- phpunit.xml.legacy | 18 ++++++++++++++++++ tests/ClientTest.php | 5 ++++- tests/TestCase.php | 8 +++++++- 7 files changed, 44 insertions(+), 8 deletions(-) create mode 100644 phpunit.xml.legacy diff --git a/.gitattributes b/.gitattributes index a353f44..404fd5d 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3,4 +3,5 @@ /.gitignore export-ignore /examples/ export-ignore /phpunit.xml.dist export-ignore +/phpunit.xml.legacy export-ignore /tests/ export-ignore diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 226e238..d321f38 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,6 +28,9 @@ jobs: coverage: xdebug - run: composer install - run: vendor/bin/phpunit --coverage-text + if: ${{ matrix.php >= 7.3 }} + - run: vendor/bin/phpunit --coverage-text -c phpunit.xml.legacy + if: ${{ matrix.php < 7.3 }} PHPUnit-hhvm: name: PHPUnit (HHVM) diff --git a/composer.json b/composer.json index 8f36bfb..e6afe8c 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ "rize/uri-template": "^0.3" }, "require-dev": { - "phpunit/phpunit": "^7.0 || ^6.0 || ^5.7 || ^4.8.35" + "phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.35" }, "autoload": { "psr-4": { "Clue\\React\\Packagist\\Api\\": "src/" } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index c4ad7fd..c93da8c 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,14 +1,19 @@ - + + ./tests/ - - + + ./src/ - - + + diff --git a/phpunit.xml.legacy b/phpunit.xml.legacy new file mode 100644 index 0000000..dda595c --- /dev/null +++ b/phpunit.xml.legacy @@ -0,0 +1,18 @@ + + + + + + + ./tests/ + + + + + ./src/ + + + diff --git a/tests/ClientTest.php b/tests/ClientTest.php index e03b0a8..f6ca3a2 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -12,7 +12,10 @@ class ClientTest extends TestCase private $browser; private $client; - public function setUp() + /** + * @before + */ + public function setUpClient() { $this->browser = $this->getMockBuilder('Clue\React\Buzz\Browser')->disableOriginalConstructor()->getMock(); $this->browser->expects($this->any())->method('withBase')->willReturn($this->browser); diff --git a/tests/TestCase.php b/tests/TestCase.php index 41dacd6..2d42363 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -46,7 +46,13 @@ protected function expectCallableOnceParameter($type) protected function createCallableMock() { - return $this->getMockBuilder('stdClass')->setMethods(array('__invoke'))->getMock(); + if (method_exists('PHPUnit\Framework\MockObject\MockBuilder', 'addMethods')) { + // PHPUnit 8.5+ + return $this->getMockBuilder('stdClass')->addMethods(array('__invoke'))->getMock(); + } else { + // legacy PHPUnit 4 - PHPUnit 8.4 + return $this->getMockBuilder('stdClass')->setMethods(array('__invoke'))->getMock(); + } } protected function expectPromiseResolve($promise) From f400646dd7bb7d4a275b1f7f990cba2e4a05c97f Mon Sep 17 00:00:00 2001 From: Simon Frings Date: Thu, 29 Jul 2021 11:43:35 +0200 Subject: [PATCH 2/2] Support PHP 8 --- .github/workflows/ci.yml | 1 + README.md | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d321f38..cf214c8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,6 +11,7 @@ jobs: strategy: matrix: php: + - 8.0 - 7.4 - 7.3 - 7.2 diff --git a/README.md b/README.md index 0b1e889..826a24b 100644 --- a/README.md +++ b/README.md @@ -240,7 +240,7 @@ $ composer require clue/packagist-api-react:^1.3 See also the [CHANGELOG](CHANGELOG.md) for details about version upgrades. This project aims to run on any platform and thus does not require any PHP -extensions and supports running on legacy PHP 5.3 through current PHP 7+ and +extensions and supports running on legacy PHP 5.3 through current PHP 8+ and HHVM. It's *highly recommended to use PHP 7+* for this project.