Skip to content

Commit

Permalink
Add support for PHP 8 (#41)
Browse files Browse the repository at this point in the history
* 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 PHP-CS-Fixer/PHP-CS-Fixer#4702).
PHPUnit option convertDeprecationsToExceptions disabled to deal with deprecated GraphQL::execute() (related to #39).
  • Loading branch information
vhenzl authored Dec 7, 2020
1 parent b557de1 commit a2a11bb
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 22 deletions.
21 changes: 8 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion lib/promise-adapter/tests/AdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

<!-- http://phpunit.de/manual/4.1/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="./vendor/autoload.php"
convertDeprecationsToExceptions="false"
>
<php>
<ini name="error_reporting" value="-1" />
Expand Down
2 changes: 1 addition & 1 deletion tests/Functional/Webonyx/GraphQL/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,6 @@ public static function build(DataLoader $dataLoader)
]
]);

return new \GraphQL\Schema(['query' => $queryType]);
return new \GraphQL\Type\Schema(['query' => $queryType]);
}
}
2 changes: 1 addition & 1 deletion tests/Functional/Webonyx/GraphQL/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit a2a11bb

Please sign in to comment.