From 44572256dae0a03d2a8ca0fbeb0879d640e8a8fb Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Tue, 1 Oct 2024 13:53:50 +0200 Subject: [PATCH] Add extra arguments to PHPUnit 10+ --- bin/run-php-unit-tests | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bin/run-php-unit-tests b/bin/run-php-unit-tests index 73032edfc..6182d0746 100755 --- a/bin/run-php-unit-tests +++ b/bin/run-php-unit-tests @@ -3,9 +3,16 @@ # Run the unit tests, if they exist if [ -f "phpunit.xml" ] || [ -f "phpunit.xml.dist" ] || [ -f ".phpunit.xml" ] || [ -f ".phpunit.xml.dist" ] then + PHPUNIT_VERSION=$(vendor/bin/phpunit --version | grep --only-matching --max-count=1 --extended-regexp '\b[0-9]+\.[0-9]+') + EXTRA_ARGS="" + + if [ "${PHPUNIT_VERSION#11}" != "$PHPUNIT_VERSION" ] || [ "${PHPUNIT_VERSION#10}" != "$PHPUNIT_VERSION" ]; then + EXTRA_ARGS="--display-warnings --fail-on-warning --display-notices --fail-on-notice --display-deprecations --fail-on-deprecation" + fi + if [ -f "./vendor/wp-cli/wp-cli-tests/tests/bootstrap.php" ]; then - vendor/bin/phpunit --color=always "$@" --bootstrap ./vendor/wp-cli/wp-cli-tests/tests/bootstrap.php + vendor/bin/phpunit --color=always "$@" $EXTRA_ARGS --bootstrap ./vendor/wp-cli/wp-cli-tests/tests/bootstrap.php else - vendor/bin/phpunit --color=always "$@" + vendor/bin/phpunit --color=always "$@" $EXTRA_ARGS fi fi