Skip to content

Commit 5ee0bce

Browse files
authored
Merge pull request #809 from Automattic/feature/phpunit-cross-version
2 parents 550ec3c + 83d152e commit 5ee0bce

File tree

9 files changed

+16
-55
lines changed

9 files changed

+16
-55
lines changed

.github/CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ When you introduce new `public` sniff properties, or your sniff extends a class
9595
* WordPress-Coding-Standards
9696
* PHPCSUtils 1.x
9797
* PHP_CodeSniffer 3.x
98-
* PHPUnit 4.x, 5.x, 6.x or 7.x
98+
* PHPUnit 4.x - 9.x
9999

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

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

108108
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.
109-
Alternatively, you can [install PHPUnit](https://phpunit.readthedocs.io/en/7.5/installation.html) as a PHAR file.
109+
Alternatively, you can [install PHPUnit](https://phpunit.readthedocs.io/en/9.6/installation.html) as a PHAR file.
110110

111111
### Before running the unit tests
112112

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

147147
Expected output:
148148
```
149-
PHPUnit 7.5.20 by Sebastian Bergmann and contributors.
149+
PHPUnit 9.6.15 by Sebastian Bergmann and contributors.
150150

151151
........................................ 40 / 40 (100%)
152152

.github/workflows/basics.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ jobs:
9090
- name: Install PHP
9191
uses: shivammathur/setup-php@v2
9292
with:
93-
php-version: '7.4'
93+
php-version: 'latest'
9494
coverage: none
9595
tools: phpstan
9696

.github/workflows/quicktest.yml

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -53,24 +53,14 @@ jobs:
5353

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

63-
# PHPUnit 7.x does not allow for installation on PHP 8, so ignore platform
64-
# requirements to get PHPUnit 7.x to install on nightly.
65-
- name: Install Composer dependencies - with ignore platform
66-
if: ${{ startsWith( matrix.php, '8' ) || matrix.php == 'latest' }}
67-
uses: "ramsey/composer-install@v2"
68-
with:
69-
composer-options: --ignore-platform-req=php+
70-
custom-cache-suffix: $(date -u "+%Y-%m")
71-
7262
- name: "Composer: downgrade PHPCS dependencies for tests (lowest)"
73-
if: ${{ matrix.php == '5.4' && matrix.dependencies == 'lowest' }}
63+
if: ${{ matrix.dependencies == 'lowest' }}
7464
run: >
7565
composer update --prefer-lowest --no-scripts --no-interaction
7666
squizlabs/php_codesniffer
@@ -79,16 +69,6 @@ jobs:
7969
sirbrillig/phpcs-variable-analysis
8070
wp-coding-standards/wpcs
8171
82-
- name: "Composer: downgrade PHPCS dependencies for tests (lowest) - with ignore platform"
83-
if: ${{ matrix.php == 'latest' && matrix.dependencies == 'lowest' }}
84-
run: >
85-
composer update --prefer-lowest --no-scripts --no-interaction --ignore-platform-req=php+
86-
squizlabs/php_codesniffer
87-
phpcsstandards/phpcsutils
88-
phpcsstandards/phpcsextra
89-
sirbrillig/phpcs-variable-analysis
90-
wp-coding-standards/wpcs
91-
9272
- name: Display PHPCS installed standards
9373
run: ./vendor/bin/phpcs -i
9474

.github/workflows/test.yml

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -125,24 +125,14 @@ jobs:
125125
126126
# Install dependencies and handle caching in one go.
127127
# @link https://github.com/marketplace/actions/install-php-dependencies-with-composer
128-
- name: Install Composer dependencies - normal
129-
if: ${{ startsWith( matrix.php, '8' ) == false }}
128+
- name: Install Composer dependencies
130129
uses: "ramsey/composer-install@v2"
131130
with:
132131
# Bust the cache at least once a month - output format: YYYY-MM.
133132
custom-cache-suffix: $(date -u "+%Y-%m")
134133

135-
# PHPUnit 7.x does not allow for installation on PHP 8, so ignore platform
136-
# requirements to get PHPUnit 7.x to install on nightly.
137-
- name: Install Composer dependencies - with ignore platform
138-
if: ${{ startsWith( matrix.php, '8' ) }}
139-
uses: "ramsey/composer-install@v2"
140-
with:
141-
composer-options: --ignore-platform-req=php+
142-
custom-cache-suffix: $(date -u "+%Y-%m")
143-
144134
- name: "Composer: downgrade PHPCS dependencies for tests (lowest)"
145-
if: ${{ ! startsWith( matrix.php, '8' ) && matrix.dependencies == 'lowest' }}
135+
if: ${{ matrix.dependencies == 'lowest' }}
146136
run: >
147137
composer update --prefer-lowest --no-scripts --no-interaction
148138
squizlabs/php_codesniffer
@@ -151,16 +141,6 @@ jobs:
151141
sirbrillig/phpcs-variable-analysis
152142
wp-coding-standards/wpcs
153143
154-
- name: "Composer: downgrade PHPCS dependencies for tests (lowest) - with ignore platform"
155-
if: ${{ startsWith( matrix.php, '8' ) && matrix.dependencies == 'lowest' }}
156-
run: >
157-
composer update --prefer-lowest --no-scripts --no-interaction --ignore-platform-req=php+
158-
squizlabs/php_codesniffer
159-
phpcsstandards/phpcsutils
160-
phpcsstandards/phpcsextra
161-
sirbrillig/phpcs-variable-analysis
162-
wp-coding-standards/wpcs
163-
164144
- name: Run the unit tests
165145
run: ./bin/unit-tests
166146

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ phpcs.xml
66
phpunit.xml
77
phpcs.cache
88
phpstan.neon
9+
.phpunit.result.cache

bin/unit-tests

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,4 @@
1616
# ./bin/unit-tests --filter SniffName
1717
#
1818

19-
if [[ $(php -r 'echo PHP_VERSION_ID;') -ge 80100 ]]; then
20-
"$(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 $@
21-
else
22-
"$(pwd)/vendor/bin/phpunit" --filter=WordPressVIPMinimum "$(pwd)/vendor/squizlabs/php_codesniffer/tests/AllTests.php" --no-coverage $@
23-
fi
19+
"$(pwd)/vendor/bin/phpunit" --filter WordPressVIPMinimum "$(pwd)/vendor/squizlabs/php_codesniffer/tests/AllTests.php" --no-coverage $@

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"php-parallel-lint/php-console-highlighter": "^1.0.0",
2929
"phpcompatibility/php-compatibility": "^9",
3030
"phpcsstandards/phpcsdevtools": "^1.0",
31-
"phpunit/phpunit": "^4 || ^5 || ^6 || ^7"
31+
"phpunit/phpunit": "^4 || ^5 || ^6 || ^7 || ^8 || ^9"
3232
},
3333
"config": {
3434
"allow-plugins": {

phpstan.neon.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
parameters:
2-
#phpVersion: 50400 # Needs to be 70100 or higher... sigh...
2+
phpVersion: 70100 # Needs to be 70100 or higher... sigh...
33
level: 5
44
paths:
55
- WordPressVIPMinimum

phpunit.xml.dist

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
backupGlobals="true"
66
bootstrap="./tests/bootstrap.php"
77
beStrictAboutTestsThatDoNotTestAnything="false"
8+
convertErrorsToExceptions="true"
9+
convertWarningsToExceptions="true"
10+
convertNoticesToExceptions="true"
11+
convertDeprecationsToExceptions="true"
812
forceCoversAnnotation="true"
913
colors="true"
1014
>

0 commit comments

Comments
 (0)