From a2a11bbde3c8c3d7235b9b4d75f420cc6cb814e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Va=C5=A1ek=20Henzl?= Date: Mon, 7 Dec 2020 20:11:35 +1300 Subject: [PATCH] Add support for PHP 8 (#41) * Drop hhvm from build matrix * Bump minimal PHP version to 7.1 * Remove PHP 7.3 from allowed failures * Add PHP 7.4 to build matrix * Check platform requirements * Replace `\PHPUnit_Framework_TestCase` with `\PHPUnit\Framework\TestCase` * Bump PHPUnit to version 7.5 * Bump `webonyx/graphql-php` to version 0.13 * Prefer package sources on `composer update` `tests/StarWarsData.php` is no longer part of `webonyx/graphql-php` package * Fix deprecation for `GraphQL\Schema` * Suppress deprecation errors in tests * Bump `webonyx/graphql-php` to version 14 * Bump PHPUnit to version 8.5 * Allow PHPUnit 7 for compatibility with PHP 7.1 * Allow PHP 8 * Use current version of `php-cs-fixer` * Switch Travis CI from `trusty` to `bionic` * Add PHP 8.0 to the build matrix * Don't run `php-cs-fixer` for PHP 8.0 Resolves #40. Minimal PHP version increased to 7.1. (So that supported versions are same as in webonyx/graphql-php. Going up to 7.2 would make things easier regarding PHPUnit.) Installation on PHP 8 allowed. composer check-platform-reqs added to build steps PHPUnit bumped to ^7.5|^8.5 to support PHP 7.1-8.0 webonyx/graphql-php updated to the current version 14 --prefer-source used for composer update as tests/StarWarsData.php is no longer part of webonyx/graphql-php package. Alternative options would be to create a local copy of the file in this repository or download it from webonyx/graphql-php repo with wget in before_install. The current version of php-cs-fixer (2.16) used, however, it doesn't allow installation on PHP 8 yet (see FriendsOfPHP/PHP-CS-Fixer#4702). PHPUnit option convertDeprecationsToExceptions disabled to deal with deprecated GraphQL::execute() (related to #39). --- .travis.yml | 21 +++++++------------ composer.json | 6 +++--- lib/promise-adapter/tests/AdapterTest.php | 2 +- phpunit.xml.dist | 3 ++- tests/Functional/Webonyx/GraphQL/Schema.php | 2 +- tests/Functional/Webonyx/GraphQL/TestCase.php | 2 +- tests/TestCase.php | 4 ++-- 7 files changed, 18 insertions(+), 22 deletions(-) diff --git a/.travis.yml b/.travis.yml index c126e32..43fd842 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,16 +1,14 @@ -dist: trusty +dist: bionic language: php php: - - 5.5 - - 5.6 - - 7.0 - 7.1 - 7.2 - 7.3 + - 7.4 + - 8.0 - nightly - - hhvm branches: only: @@ -20,21 +18,18 @@ branches: matrix: allow_failures: - php: nightly - - php: 7.3 cache: directories: - $HOME/.composer/cache before_install: - - if [[ "$TRAVIS_PHP_VERSION" != "5.6" && "$TRAVIS_PHP_VERSION" != "hhvm" ]]; then phpenv config-rm xdebug.ini || true; fi + - phpenv config-rm xdebug.ini || true - composer selfupdate -install: composer update --prefer-dist --no-interaction +install: composer update --prefer-source --no-interaction script: - - if [ "$TRAVIS_PHP_VERSION" == "5.6" ]; then bin/phpunit --debug --coverage-clover build/logs/clover.xml; else bin/phpunit --debug; fi - - if [ "$TRAVIS_PHP_VERSION" == "7.0" ]; then composer require "friendsofphp/php-cs-fixer:^2.0" && bin/php-cs-fixer fix --diff --dry-run -v; fi; - -after_success: - - if [ "$TRAVIS_PHP_VERSION" == "5.6" ]; then composer require "satooshi/php-coveralls:^1.0" && travis_retry php bin/coveralls -v; fi + - composer check-platform-reqs + - bin/phpunit --debug + - if [ "$TRAVIS_PHP_VERSION" != "8.0" ]; then composer require "friendsofphp/php-cs-fixer:^2.16" && bin/php-cs-fixer fix --diff --dry-run -v; fi diff --git a/composer.json b/composer.json index d90b0ca..70bbe0a 100644 --- a/composer.json +++ b/composer.json @@ -27,13 +27,13 @@ "overblog/promise-adapter": "self.version" }, "require": { - "php": "^5.5|^7.0" + "php": "^7.1|^8.0" }, "require-dev": { "guzzlehttp/promises": "^1.3.0", - "phpunit/phpunit": "^4.1|^5.1", + "phpunit/phpunit": "^7.5|^8.5", "react/promise": "^2.5.0", - "webonyx/graphql-php": "^0.11.0" + "webonyx/graphql-php": "^14.0" }, "suggest": { "guzzlehttp/promises": "To use with Guzzle promise", diff --git a/lib/promise-adapter/tests/AdapterTest.php b/lib/promise-adapter/tests/AdapterTest.php index a51e9e1..6b40ea2 100644 --- a/lib/promise-adapter/tests/AdapterTest.php +++ b/lib/promise-adapter/tests/AdapterTest.php @@ -16,7 +16,7 @@ use Overblog\PromiseAdapter\Adapter\WebonyxGraphQLSyncPromiseAdapter; use Overblog\PromiseAdapter\PromiseAdapterInterface; -class AdapterTest extends \PHPUnit_Framework_TestCase +class AdapterTest extends \PHPUnit\Framework\TestCase { /** * @dataProvider AdapterDataProvider diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 14c5b99..7846ca1 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -2,10 +2,11 @@ diff --git a/tests/Functional/Webonyx/GraphQL/Schema.php b/tests/Functional/Webonyx/GraphQL/Schema.php index 7219a54..f37d339 100644 --- a/tests/Functional/Webonyx/GraphQL/Schema.php +++ b/tests/Functional/Webonyx/GraphQL/Schema.php @@ -81,6 +81,6 @@ public static function build(DataLoader $dataLoader) ] ]); - return new \GraphQL\Schema(['query' => $queryType]); + return new \GraphQL\Type\Schema(['query' => $queryType]); } } diff --git a/tests/Functional/Webonyx/GraphQL/TestCase.php b/tests/Functional/Webonyx/GraphQL/TestCase.php index 1cc7ec1..e5298c7 100644 --- a/tests/Functional/Webonyx/GraphQL/TestCase.php +++ b/tests/Functional/Webonyx/GraphQL/TestCase.php @@ -18,7 +18,7 @@ use Overblog\DataLoader\DataLoader; use Overblog\PromiseAdapter\PromiseAdapterInterface; -abstract class TestCase extends \PHPUnit_Framework_TestCase +abstract class TestCase extends \PHPUnit\Framework\TestCase { private static $fixtures = null; diff --git a/tests/TestCase.php b/tests/TestCase.php index 2359a79..755ef26 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -14,14 +14,14 @@ use Overblog\PromiseAdapter\Adapter\ReactPromiseAdapter; use Overblog\PromiseAdapter\PromiseAdapterInterface; -abstract class TestCase extends \PHPUnit_Framework_TestCase +abstract class TestCase extends \PHPUnit\Framework\TestCase { /** * @var PromiseAdapterInterface */ protected static $promiseAdapter; - public function setUp() + public function setUp(): void { self::$promiseAdapter = new ReactPromiseAdapter(); }