Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests: allow for PHPUnit 8/9 #809

Merged
merged 1 commit into from
Feb 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ When you introduce new `public` sniff properties, or your sniff extends a class
* WordPress-Coding-Standards
* PHPCSUtils 1.x
* PHP_CodeSniffer 3.x
* PHPUnit 4.x, 5.x, 6.x or 7.x
* PHPUnit 4.x - 9.x

The VIP Coding Standards use the PHP_CodeSniffer native unit test suite for unit testing the sniffs.

Expand All @@ -106,7 +106,7 @@ N.B.: If you installed VIPCS using Composer, make sure you used `--prefer-source
If you already have PHPUnit installed on your system: Congrats, you're all set.

If not, you can navigate to the directory where the `PHP_CodeSniffer` repo is checked out and do `composer install` to install the `dev` dependencies.
Alternatively, you can [install PHPUnit](https://phpunit.readthedocs.io/en/7.5/installation.html) as a PHAR file.
Alternatively, you can [install PHPUnit](https://phpunit.readthedocs.io/en/9.6/installation.html) as a PHAR file.

### Before running the unit tests

Expand Down Expand Up @@ -146,7 +146,7 @@ The easiest way to do this is to add a `phpunit.xml` file to the root of your VI

Expected output:
```
PHPUnit 7.5.20 by Sebastian Bergmann and contributors.
PHPUnit 9.6.15 by Sebastian Bergmann and contributors.

........................................ 40 / 40 (100%)

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/basics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ jobs:
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
php-version: 'latest'
coverage: none
tools: phpstan

Expand Down
24 changes: 2 additions & 22 deletions .github/workflows/quicktest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,24 +53,14 @@ jobs:

# Install dependencies and handle caching in one go.
# @link https://github.com/marketplace/actions/install-php-dependencies-with-composer
- name: Install Composer dependencies - normal
if: ${{ startsWith( matrix.php, '8' ) == false && matrix.php != 'latest' }}
- name: Install Composer dependencies
uses: "ramsey/composer-install@v2"
with:
# Bust the cache at least once a month - output format: YYYY-MM.
custom-cache-suffix: $(date -u "+%Y-%m")

# PHPUnit 7.x does not allow for installation on PHP 8, so ignore platform
# requirements to get PHPUnit 7.x to install on nightly.
- name: Install Composer dependencies - with ignore platform
if: ${{ startsWith( matrix.php, '8' ) || matrix.php == 'latest' }}
uses: "ramsey/composer-install@v2"
with:
composer-options: --ignore-platform-req=php+
custom-cache-suffix: $(date -u "+%Y-%m")

- name: "Composer: downgrade PHPCS dependencies for tests (lowest)"
if: ${{ matrix.php == '5.4' && matrix.dependencies == 'lowest' }}
if: ${{ matrix.dependencies == 'lowest' }}
run: >
composer update --prefer-lowest --no-scripts --no-interaction
squizlabs/php_codesniffer
Expand All @@ -79,16 +69,6 @@ jobs:
sirbrillig/phpcs-variable-analysis
wp-coding-standards/wpcs

- name: "Composer: downgrade PHPCS dependencies for tests (lowest) - with ignore platform"
if: ${{ matrix.php == 'latest' && matrix.dependencies == 'lowest' }}
run: >
composer update --prefer-lowest --no-scripts --no-interaction --ignore-platform-req=php+
squizlabs/php_codesniffer
phpcsstandards/phpcsutils
phpcsstandards/phpcsextra
sirbrillig/phpcs-variable-analysis
wp-coding-standards/wpcs

- name: Display PHPCS installed standards
run: ./vendor/bin/phpcs -i

Expand Down
24 changes: 2 additions & 22 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,24 +125,14 @@ jobs:

# Install dependencies and handle caching in one go.
# @link https://github.com/marketplace/actions/install-php-dependencies-with-composer
- name: Install Composer dependencies - normal
if: ${{ startsWith( matrix.php, '8' ) == false }}
- name: Install Composer dependencies
uses: "ramsey/composer-install@v2"
with:
# Bust the cache at least once a month - output format: YYYY-MM.
custom-cache-suffix: $(date -u "+%Y-%m")

# PHPUnit 7.x does not allow for installation on PHP 8, so ignore platform
# requirements to get PHPUnit 7.x to install on nightly.
- name: Install Composer dependencies - with ignore platform
if: ${{ startsWith( matrix.php, '8' ) }}
uses: "ramsey/composer-install@v2"
with:
composer-options: --ignore-platform-req=php+
custom-cache-suffix: $(date -u "+%Y-%m")

- name: "Composer: downgrade PHPCS dependencies for tests (lowest)"
if: ${{ ! startsWith( matrix.php, '8' ) && matrix.dependencies == 'lowest' }}
if: ${{ matrix.dependencies == 'lowest' }}
run: >
composer update --prefer-lowest --no-scripts --no-interaction
squizlabs/php_codesniffer
Expand All @@ -151,16 +141,6 @@ jobs:
sirbrillig/phpcs-variable-analysis
wp-coding-standards/wpcs

- name: "Composer: downgrade PHPCS dependencies for tests (lowest) - with ignore platform"
if: ${{ startsWith( matrix.php, '8' ) && matrix.dependencies == 'lowest' }}
run: >
composer update --prefer-lowest --no-scripts --no-interaction --ignore-platform-req=php+
squizlabs/php_codesniffer
phpcsstandards/phpcsutils
phpcsstandards/phpcsextra
sirbrillig/phpcs-variable-analysis
wp-coding-standards/wpcs

- name: Run the unit tests
run: ./bin/unit-tests

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ phpcs.xml
phpunit.xml
phpcs.cache
phpstan.neon
.phpunit.result.cache
6 changes: 1 addition & 5 deletions bin/unit-tests
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,4 @@
# ./bin/unit-tests --filter SniffName
#

if [[ $(php -r 'echo PHP_VERSION_ID;') -ge 80100 ]]; then
"$(pwd)/vendor/bin/phpunit" --filter=WordPressVIPMinimum "$(pwd)/vendor/squizlabs/php_codesniffer/tests/AllTests.php" --no-coverage --no-configuration --bootstrap=./tests/bootstrap.php --dont-report-useless-tests $@
else
"$(pwd)/vendor/bin/phpunit" --filter=WordPressVIPMinimum "$(pwd)/vendor/squizlabs/php_codesniffer/tests/AllTests.php" --no-coverage $@
fi
"$(pwd)/vendor/bin/phpunit" --filter WordPressVIPMinimum "$(pwd)/vendor/squizlabs/php_codesniffer/tests/AllTests.php" --no-coverage $@
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"php-parallel-lint/php-console-highlighter": "^1.0.0",
"phpcompatibility/php-compatibility": "^9",
"phpcsstandards/phpcsdevtools": "^1.0",
"phpunit/phpunit": "^4 || ^5 || ^6 || ^7"
"phpunit/phpunit": "^4 || ^5 || ^6 || ^7 || ^8 || ^9"
},
"config": {
"allow-plugins": {
Expand Down
2 changes: 1 addition & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
parameters:
#phpVersion: 50400 # Needs to be 70100 or higher... sigh...
phpVersion: 70100 # Needs to be 70100 or higher... sigh...
GaryJones marked this conversation as resolved.
Show resolved Hide resolved
level: 5
paths:
- WordPressVIPMinimum
Expand Down
4 changes: 4 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
backupGlobals="true"
bootstrap="./tests/bootstrap.php"
beStrictAboutTestsThatDoNotTestAnything="false"
convertErrorsToExceptions="true"
convertWarningsToExceptions="true"
convertNoticesToExceptions="true"
convertDeprecationsToExceptions="true"
forceCoversAnnotation="true"
colors="true"
>
Expand Down
Loading