Skip to content

Commit

Permalink
Update phpunit if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
swissspidy committed Nov 9, 2023
1 parent af49877 commit 53fc7f1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/php-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,38 @@ jobs:
with:
php-version: ${{ matrix.php }}

- name: Install PHP dependencies
uses: ramsey/composer-install@v2
with:
composer-options: '--prefer-dist --no-progress --no-interaction --no-scripts'

# Installs a different PHPUnit version depending on the PHP version we're testing against.
#
# | WP / PHP | PHPUnit |
# |-----------|---------|
# | * / 7.0 | 6 |
# | * / 7.1 | 7 |
# | * / 7.2 | 8 |
# | * / 7.3 | 9 |
# | * / 7.4 | 9 |
# | * / 8 | 9 |
#
# See https://make.wordpress.org/core/handbook/references/phpunit-compatibility-and-wordpress-versions/
- name: Update PHPUnit
run: |
if [[ $PHP_VERSION == "7.1" ]]; then
echo "Installing PHPUnit 7.5x"
composer require --ignore-platform-reqs --no-interaction --no-scripts phpunit/phpunit:^7.5 --with-dependencies
elif [[ $PHP_VERSION == "7.2" ]]; then
echo "Installing PHPUnit 8.5x"
composer require --ignore-platform-reqs --no-interaction --no-scripts phpunit/phpunit:^8.5 --with-dependencies
else
echo "Installing latest version of PHPUnit"
composer update --ignore-platform-reqs --no-interaction --no-scripts yoast/phpunit-polyfills --with-dependencies
fi
env:
PHP_VERSION: ${{ matrix.php }}

- name: Setup Node.js (.nvmrc)
uses: actions/setup-node@v3
with:
Expand Down
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@
"phpstan": "wp-env run tests-cli --env-cwd=wp-content/plugins/plugin-check/ composer run-script phpstan",
"lint-php": "wp-env run tests-cli --env-cwd=wp-content/plugins/plugin-check/ composer run-script lint",
"format-php": "wp-env run tests-cli --env-cwd=wp-content/plugins/plugin-check/ composer run-script format",
"pretest-php": "wp-env run tests-cli --env-cwd=wp-content/plugins/plugin-check/ composer install --no-interaction",
"test-php": "wp-env run tests-cli --env-cwd=/var/www/html/wp-content/plugins/plugin-check/ vendor/bin/phpunit --verbose",
"pretest-php-coverage": "wp-env run tests-cli --env-cwd=/var/www/html/wp-content/plugins/plugin-check/ composer install --no-interaction",
"test-php-coverage": "wp-env run tests-cli --env-cwd=/var/www/html/wp-content/plugins/plugin-check/ vendor/bin/phpunit --verbose --coverage-clover build/logs/php-coverage.xml",
"test-php-multisite": "wp-env run tests-cli --env-cwd=/var/www/html/wp-content/plugins/plugin-check/ vendor/bin/phpunit -c tests/phpunit/multisite.xml --verbose",
"test-php-multisite-coverage": "wp-env run tests-cli --env-cwd=/var/www/html/wp-content/plugins/plugin-check/ vendor/bin/phpunit -c tests/phpunit/multisite.xml --verbose --coverage-clover build/logs/php-coverage-multisite.xml"
Expand Down

0 comments on commit 53fc7f1

Please sign in to comment.