Build/Test Tools: Add NPM script for using the Composer installed version of PHPUnit.

The `test:php` NPM script runs the PHP test suite using the system installed version of PHPUnit. In some cases, the version of PHPUnit installed through Composer may be preferred.

Currently, this is true when running the test suite using PHP 8. In order to add support for PHP 8 while maintaining compatibility for PHP 5.6.20, PHPUnit 7.x must be used. But, some modifications are required to be compatible with PHP 8 (see [49037], [48957]).

This change introduces the `test:php-composer` NPM script, which will run the test suite using the composer installed version.

Props desrosj, SergeyBiryukov.
Fixes #51456.

git-svn-id: https://develop.svn.wordpress.org/trunk@49099 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jonathan Desrosiers 2020-10-07 13:08:20 +00:00
parent 26a18bc72c
commit 683ecf8c6a
2 changed files with 7 additions and 6 deletions

View File

@ -42,12 +42,12 @@ jobs:
script: script:
# The PHPUnit 7.x phar is not compatible with PHP 8 and won't be updated, # The PHPUnit 7.x phar is not compatible with PHP 8 and won't be updated,
# as PHPUnit 7 is no longer supported, so run the Composer-installed PHPUnit instead. # as PHPUnit 7 is no longer supported, so run the Composer-installed PHPUnit instead.
- docker-compose run --rm phpunit php ./vendor/bin/phpunit --verbose -c phpunit.xml.dist - npm run test:php-composer --verbose -c phpunit.xml.dist
- docker-compose run --rm phpunit php ./vendor/bin/phpunit --verbose -c phpunit.xml.dist --group ajax - npm run test:php-composer --verbose -c phpunit.xml.dist --group ajax
- docker-compose run --rm phpunit php ./vendor/bin/phpunit --verbose -c tests/phpunit/multisite.xml - npm run test:php-composer --verbose -c tests/phpunit/multisite.xml
- docker-compose run --rm phpunit php ./vendor/bin/phpunit --verbose -c tests/phpunit/multisite.xml --group ms-files - npm run test:php-composer --verbose -c tests/phpunit/multisite.xml --group ms-files
- docker-compose run --rm phpunit php ./vendor/bin/phpunit --verbose -c phpunit.xml.dist --group external-http - npm run test:php-composer --verbose -c phpunit.xml.dist --group external-http
- docker-compose run --rm phpunit php ./vendor/bin/phpunit --verbose -c phpunit.xml.dist --group restapi-jsclient - npm run test:php-composer --verbose -c phpunit.xml.dist --group restapi-jsclient
# __fakegroup__ is excluded to force PHPUnit to ignore the <exclude> settings in phpunit.xml.dist. # __fakegroup__ is excluded to force PHPUnit to ignore the <exclude> settings in phpunit.xml.dist.
# Xdebug supports PHP 8 only from version 3.0, which is not released yet. # Xdebug supports PHP 8 only from version 3.0, which is not released yet.
# Once Xdebug 3.0 is released and included in the Docker image, this should be uncommented again. # Once Xdebug 3.0 is released and included in the Docker image, this should be uncommented again.

View File

@ -167,6 +167,7 @@
"env:logs": "node ./tools/local-env/scripts/docker.js logs", "env:logs": "node ./tools/local-env/scripts/docker.js logs",
"env:pull": "node ./tools/local-env/scripts/docker.js pull", "env:pull": "node ./tools/local-env/scripts/docker.js pull",
"test:php": "node ./tools/local-env/scripts/docker.js run --rm phpunit phpunit", "test:php": "node ./tools/local-env/scripts/docker.js run --rm phpunit phpunit",
"test:php-composer": "node ./tools/local-env/scripts/docker.js run --rm phpunit php ./vendor/bin/phpunit",
"test:e2e": "node ./tests/e2e/run-tests.js" "test:e2e": "node ./tests/e2e/run-tests.js"
} }
} }