Skip to content

Commit 76999f6

Browse files
committed
Travis: test builds against PHP 7.4 & improve PHPUnit 8 fix
Nightly has become PHP 8.0 since PHP 7.4 has been branched, so to continue to also test against PHP 7.4, it needs to be added separately. As PHPStan can't currently be run (yet) on PHP 8, the environment variable for it has also been moved to PHP 7.4. Refs: * https://twitter.com/nikita_ppv/status/1089839541828112384 * https://twitter.com/nikita_ppv/status/1094897743594770433 PHPUnit 8 adds `void` return type declarations to the PHPUnit methods used by PHPCS, making it neigh impossible to make the unit test suite cross-version compatible for the PHP versions supported by PHPCS. Officially, PHPUnit 7 is compatible with PHP 7.1, 7.2 and 7.3. However for the functionality used by the PHPCS test suite, it looks to be compatible with PHP 7.4 as well (for now). Ref: https://phpunit.de/supported-versions.html For this reason, for Travis images which come natively with PHPUnit 8 (PHP >= 7.2), PHPUnit 7 needs to be installed via Composer. This is not necessary for older PHP versions and skipping the `composer install` when it's not needed, will make the build a little faster. Note: Doing the `composer install` in the `before_install` step will show a build as "errored" instead of "failed" if something would go wong with this install, which is more representative of the real build status. As for `nightly`/PHP 8: * The Travis native PHPUnit version for `nightly` is PHPUnit 8, which will not work. * Running `composer install` for PHPUnit on `nightly` currently installs PHPUnit 4.1.6. Most likely because the PHPUnit 4.x `composer.json` file did not yet contain a PHP requirement, while any higher PHPUnit versions do. Anyways, that will most definitely not work. * Running `composer install` for PHPUnit with a requirement of PHPUnit 7.x will also not work as PHPUnit 7 will not install on PHP 8 based on the PHPUnit `composer.json` file. All in all, the unit tests can not currently be run on PHP 8. When the PHPUnit build step would be active on `nightly` it would automatically fail the build. This would mask any errors in other build steps. So, for now, I've elected to skip running the unit tests on PHP 8 (`nightly`). This will allow all the other build tests which *can* be run on PHP 8 to still be tested and report appropriate statuses.
1 parent a982ecd commit 76999f6

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

.travis.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,35 @@ matrix:
1919
env: CUSTOM_INI=1 PEAR_VALIDATE=1
2020
- php: 7.1
2121
- php: 7.2
22+
env: PHPUNIT_INCOMPAT=1
2223
- php: 7.3
24+
env: PHPUNIT_INCOMPAT=1
25+
- php: "7.4snapshot"
26+
env: PHPSTAN=1 PHPUNIT_INCOMPAT=1
27+
# Nightly is PHP 8.0 since Feb 2019.
2328
- php: nightly
24-
env: PHPSTAN=1
29+
env: PHPUNIT_INCOMPAT=1
2530

2631
allow_failures:
32+
- php: "7.4snapshot"
2733
- php: nightly
2834

2935
before_install:
3036
- export XMLLINT_INDENT=" "
3137
# Speed up build time by disabling Xdebug when its not needed.
3238
- phpenv config-rm xdebug.ini || echo 'No xdebug config.'
39+
# PHPUnit 8.x is not (yet) supported, so prevent issues with Travis images using it.
40+
- if [[ $PHPUNIT_INCOMPAT == "1" && $TRAVIS_PHP_VERSION != "nightly" ]]; then composer install; fi
3341

3442
before_script:
3543
- if [[ $CUSTOM_INI == "1" && ${TRAVIS_PHP_VERSION:0:1} == "5" ]]; then phpenv config-add php5-testingConfig.ini; fi
3644
- if [[ $CUSTOM_INI == "1" ]] && [[ ${TRAVIS_PHP_VERSION:0:1} == "7" || $TRAVIS_PHP_VERSION == "nightly" ]]; then phpenv config-add php7-testingConfig.ini; fi
3745

3846
script:
39-
- composer install
4047
- php bin/phpcs --config-set php_path php
41-
- vendor/bin/phpunit tests/AllTests.php
48+
- if [[ $PHPUNIT_INCOMPAT != "1" ]]; then phpunit tests/AllTests.php; fi
49+
# Don't run the unit tests on nightly (PHP 8.0) as there is no compatible PHPUnit version available yet.
50+
- if [[ $PHPUNIT_INCOMPAT == "1" && $TRAVIS_PHP_VERSION != "nightly" ]]; then vendor/bin/phpunit tests/AllTests.php; fi
4251
- if [[ $CUSTOM_INI != "1" ]]; then php bin/phpcs --no-cache --parallel=1; fi
4352
- if [[ $CUSTOM_INI != "1" && $TRAVIS_PHP_VERSION != "nightly" ]]; then pear package-validate package.xml; fi
4453
- if [[ $PEAR_VALIDATE == "1" ]]; then php scripts/validate-pear-package.php; fi

0 commit comments

Comments
 (0)