Skip to content

Commit 4426a06

Browse files
committed
Travis: work around PHPUnit 8.x on PHP >= 7.2 images
As of recently, the Travis images for PHP 7.2+ ship with PHPUnit 8.x. The PHPCS native test framework is not compatible with PHPUnit 8.x and won't be able to be made compatible with it until the minimum PHP version would be raised to PHP 7.1. So for the unit tests to be able to run on PHP 7.2+, we need to explicitly require PHPUnit 7.x for those builds. This has been implemented in the same way as a similar requirement was previously implemented fo HHVM. As for nightly: there is no PHPUnit version which is currently compatible with PHP 8. As that either mean that the builds for `nightly` would always fail or - if the unit tests would be skipped -, the only check executed on `nightly` would be linting the files, I've elected to remove build testing against `nightly` for the time being.
1 parent ca209e7 commit 4426a06

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

.travis.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ php:
2222
- 7.2
2323
- 7.3
2424
- "7.4snapshot"
25-
- nightly
2625

2726
env:
2827
# `master` is now 3.x.
@@ -44,7 +43,6 @@ matrix:
4443
allow_failures:
4544
# Allow failures for unstable builds.
4645
- php: "7.4snapshot"
47-
- php: nightly
4846

4947
before_install:
5048
# Speed up build time by disabling Xdebug.
@@ -62,12 +60,20 @@ before_install:
6260
# The above require already does the install.
6361
$(pwd)/vendor/bin/phpcs --config-set installed_paths $(pwd)
6462
fi
63+
# Download PHPUnit 7.x for builds on PHP >= 7.2 as the PHPCS
64+
# test suite is currently not compatible with PHPUnit 8.x.
65+
- if [[ ${TRAVIS_PHP_VERSION:0:3} > "7.1" ]]; then wget -P $PHPUNIT_DIR https://phar.phpunit.de/phpunit-7.phar && chmod +x $PHPUNIT_DIR/phpunit-7.phar; fi
6566

6667
script:
6768
# Lint the PHP files against parse errors.
6869
- if [[ "$LINT" == "1" ]]; then if find . -path ./vendor -prune -o -path ./bin -prune -o -name "*.php" -exec php -l {} \; | grep "^[Parse error|Fatal error]"; then exit 1; fi; fi
6970
# Run the unit tests.
70-
- phpunit --filter WordPress --bootstrap="$(pwd)/vendor/squizlabs/php_codesniffer/tests/bootstrap.php" $(pwd)/vendor/squizlabs/php_codesniffer/tests/AllTests.php
71+
- |
72+
if [[ ${TRAVIS_PHP_VERSION:0:3} > "7.1" ]]; then
73+
php $PHPUNIT_DIR/phpunit-7.phar --filter WordPress --bootstrap="$(pwd)/vendor/squizlabs/php_codesniffer/tests/bootstrap.php" $(pwd)/vendor/squizlabs/php_codesniffer/tests/AllTests.php
74+
else
75+
phpunit --filter WordPress --bootstrap="$(pwd)/vendor/squizlabs/php_codesniffer/tests/bootstrap.php" $(pwd)/vendor/squizlabs/php_codesniffer/tests/AllTests.php
76+
fi
7177
# Test for fixer conflicts by running the auto-fixers of the complete WPCS over the test case files.
7278
# This is not an exhaustive test, but should give an early indication for typical fixer conflicts.
7379
# For the first run, the exit code will be 1 (= all fixable errors fixed).

0 commit comments

Comments
 (0)