Skip to content

Commit c1e2dd8

Browse files
committed
PHPUnit 10
2 parents e233fcb + 9291fc9 commit c1e2dd8

22 files changed

+3370
-991
lines changed

.github/workflows/lint.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,15 @@ jobs:
3939
coverage: "none"
4040
php-version: "${{ matrix.php-version }}"
4141

42+
- name: "Downgrade PHPUnit"
43+
if: matrix.php-version == '7.4' || matrix.php-version == '8.0'
44+
run: "composer require --dev phpunit/phpunit:^9.6 sebastian/diff:^4.0 --update-with-dependencies --ignore-platform-reqs"
45+
4246
- name: "Install dependencies"
4347
run: "composer install --no-interaction --no-progress"
4448

4549
- name: "Transform source code"
46-
if: matrix.php-version != '8.1' && matrix.php-version != '8.2' && matrix.php-version != '8.3' && matrix.php-version != '8.4'
50+
if: matrix.php-version == '7.4' || matrix.php-version == '8.0'
4751
run: |
4852
composer install --no-interaction --no-progress --working-dir=compiler
4953
./compiler/vendor/bin/simple-downgrade downgrade -c build/downgrade.php ${{ matrix.php-version }}

.github/workflows/phar.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ jobs:
4141
- name: "Install dependencies"
4242
run: "composer install --no-interaction --no-progress"
4343

44+
# only sebastian/diff ^4 supports PHP 7.4 so we need that in the PHAR
45+
- name: "Downgrade PHPUnit"
46+
run: "composer require --dev phpunit/phpunit:^9.6 sebastian/diff:^4.0 --update-with-dependencies --ignore-platform-reqs"
47+
4448
- name: "Install compiler dependencies"
4549
run: "composer install --no-interaction --no-progress --working-dir=compiler"
4650

.github/workflows/reflection-golden-test.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ jobs:
100100
run: "composer install --no-interaction --no-progress"
101101

102102
- name: "Transform source code"
103-
if: matrix.php-version != '8.1' && matrix.php-version != '8.2' && matrix.php-version != '8.3' && matrix.php-version != '8.4'
103+
if: matrix.php-version == '7.4' || matrix.php-version == '8.0'
104104
run: |
105105
composer install --no-interaction --no-progress --working-dir=compiler
106106
./compiler/vendor/bin/simple-downgrade downgrade -c build/downgrade.php ${{ matrix.php-version }}
@@ -118,11 +118,15 @@ jobs:
118118
- name: "Checkout"
119119
uses: actions/checkout@v4
120120

121+
- name: "Downgrade PHPUnit"
122+
if: matrix.php-version == '7.4' || matrix.php-version == '8.0'
123+
run: "composer require --dev phpunit/phpunit:^9.6 sebastian/diff:^4.0 --update-with-dependencies --ignore-platform-reqs"
124+
121125
- name: "Install dependencies"
122126
run: "composer install --no-interaction --no-progress"
123127

124128
- name: "Transform source code"
125-
if: matrix.php-version != '8.1' && matrix.php-version != '8.2' && matrix.php-version != '8.3' && matrix.php-version != '8.4'
129+
if: matrix.php-version == '7.4' || matrix.php-version == '8.0'
126130
run: |
127131
composer install --no-interaction --no-progress --working-dir=compiler
128132
./compiler/vendor/bin/simple-downgrade downgrade -c build/downgrade.php ${{ matrix.php-version }}

.github/workflows/static-analysis.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,22 @@ jobs:
4848
ini-file: development
4949
extensions: mbstring
5050

51+
- name: "Downgrade PHPUnit"
52+
if: matrix.php-version == '7.4' || matrix.php-version == '8.0'
53+
shell: bash
54+
run: "composer require --dev phpunit/phpunit:^9.6 sebastian/diff:^4.0 --update-with-dependencies --ignore-platform-reqs"
55+
5156
- name: "Install dependencies"
5257
run: "composer install --no-interaction --no-progress"
5358

5459
- name: "Transform source code"
55-
if: matrix.php-version != '8.1' && matrix.php-version != '8.2' && matrix.php-version != '8.3' && matrix.php-version != '8.4'
60+
if: matrix.php-version == '7.4' || matrix.php-version == '8.0'
5661
shell: bash
5762
run: |
5863
composer install --no-interaction --no-progress --working-dir=compiler
5964
./compiler/vendor/bin/simple-downgrade downgrade -c build/downgrade.php ${{ matrix.php-version }}
6065
composer dump
6166
62-
6367
- name: "PHPStan"
6468
run: "make phpstan"
6569

.github/workflows/tests.yml

Lines changed: 50 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ jobs:
3232
fail-fast: false
3333
matrix:
3434
php-version:
35-
- "7.4"
36-
- "8.0"
3735
- "8.1"
3836
- "8.2"
3937
- "8.3"
@@ -57,15 +55,6 @@ jobs:
5755
- name: "Install dependencies"
5856
run: "composer install --no-interaction --no-progress"
5957

60-
- name: "Transform source code"
61-
if: matrix.php-version != '8.1' && matrix.php-version != '8.2' && matrix.php-version != '8.3' && matrix.php-version != '8.4'
62-
shell: bash
63-
run: |
64-
composer install --no-interaction --no-progress --working-dir=compiler
65-
./compiler/vendor/bin/simple-downgrade downgrade -c build/downgrade.php ${{ matrix.php-version }}
66-
composer dump
67-
68-
6958
- name: "Tests"
7059
run: "make tests"
7160

@@ -118,8 +107,8 @@ jobs:
118107
ini-file: development
119108
ini-values: memory_limit=1G
120109

121-
- name: "Install PHPUnit 10.x"
122-
run: "composer remove --dev brianium/paratest && composer require --dev --with-all-dependencies phpunit/phpunit:^10 sebastian/diff:^5.0"
110+
- name: "Install dependencies"
111+
run: "composer install --no-interaction --no-progress"
123112

124113
- id: set-matrix
125114
run: echo "matrix=$(php .github/workflows/tests-levels-matrix.php)" >> $GITHUB_OUTPUT
@@ -158,3 +147,51 @@ jobs:
158147

159148
- name: "Tests"
160149
run: "${{ matrix.script }}"
150+
151+
tests-with-old-phpunit:
152+
name: "Tests with old PHPUnit"
153+
runs-on: ${{ matrix.operating-system }}
154+
timeout-minutes: 60
155+
156+
strategy:
157+
fail-fast: false
158+
matrix:
159+
php-version:
160+
- "7.4"
161+
- "8.0"
162+
operating-system: [ ubuntu-latest, windows-latest ]
163+
164+
steps:
165+
- name: "Checkout"
166+
uses: actions/checkout@v4
167+
168+
- name: "Install PHP"
169+
uses: "shivammathur/setup-php@v2"
170+
with:
171+
coverage: "none"
172+
php-version: "${{ matrix.php-version }}"
173+
tools: pecl
174+
extensions: ds,mbstring
175+
ini-file: development
176+
ini-values: memory_limit=2G
177+
178+
- name: "Downgrade PHPUnit"
179+
shell: bash
180+
run: "composer require --dev phpunit/phpunit:^9.6 sebastian/diff:^4.0 --update-with-dependencies --ignore-platform-reqs"
181+
182+
- name: "Install dependencies"
183+
run: "composer install --no-interaction --no-progress"
184+
185+
- name: "Downgrade PHPUnit with Paratest"
186+
shell: bash
187+
run: "composer require --dev phpunit/phpunit:^9.6 brianium/paratest:^6.5 symfony/console:^5.4 symfony/process:^5.4 --update-with-dependencies --ignore-platform-reqs --working-dir=tests"
188+
189+
- name: "Transform source code"
190+
shell: bash
191+
run: |
192+
composer install --no-interaction --no-progress --working-dir=compiler
193+
./compiler/vendor/bin/simple-downgrade downgrade -c build/downgrade.php ${{ matrix.php-version }}
194+
composer dump
195+
196+
- name: "Tests"
197+
run: "make tests"

Makefile

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,14 @@
22

33
build: cs tests phpstan
44

5-
tests:
6-
XDEBUG_MODE=off php vendor/bin/paratest --runner WrapperRunner --no-coverage
5+
tests: install-paratest
6+
XDEBUG_MODE=off php tests/vendor/bin/paratest --runner WrapperRunner --no-coverage
77

8-
tests-integration:
9-
php vendor/bin/paratest --runner WrapperRunner --no-coverage --group exec
10-
11-
tests-levels:
12-
php vendor/bin/paratest --runner WrapperRunner --no-coverage --group levels
13-
14-
tests-coverage:
15-
php vendor/bin/paratest --runner WrapperRunner
8+
tests-integration: install-paratest
9+
php tests/vendor/bin/paratest --runner WrapperRunner --no-coverage --group exec
1610

1711
tests-golden-reflection:
18-
php vendor/bin/paratest --runner WrapperRunner --no-coverage tests/PHPStan/Reflection/ReflectionProviderGoldenTest.php
12+
php vendor/bin/phpunit tests/PHPStan/Reflection/ReflectionProviderGoldenTest.php
1913

2014
lint:
2115
XDEBUG_MODE=off php vendor/bin/parallel-lint --colors \
@@ -113,6 +107,9 @@ lint:
113107
--exclude tests/PHPStan/Rules/Playground/data/promote-missing-override.php \
114108
src tests
115109

110+
install-paratest:
111+
composer install --working-dir tests
112+
116113
cs:
117114
composer install --working-dir build-cs && XDEBUG_MODE=off php build-cs/vendor/bin/phpcs
118115

build/ignore-by-php-version.neon.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@
3333
$includes[] = __DIR__ . '/deprecated-8.4.neon';
3434
}
3535

36+
if (PHP_VERSION_ID < 80100) {
37+
$includes[] = __DIR__ . '/old-phpunit.neon';
38+
} else {
39+
$includes[] = __DIR__ . '/new-phpunit.neon';
40+
}
3641
$config = [];
3742
$config['includes'] = $includes;
3843

build/new-phpunit.neon

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
parameters:
2+
ignoreErrors:
3+
-
4+
message: '#^Call to an undefined static method PHPUnit\\Framework\\TestCase\:\:assertFileNotExists\(\)\.$#'
5+
identifier: staticMethod.notFound
6+
count: 1
7+
path: ../src/Testing/LevelsTestCase.php

build/old-phpunit.neon

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
parameters:
2+
ignoreErrors:
3+
-
4+
message: '#^Instanceof references internal interface PHPUnit\\Exception\.$#'
5+
identifier: instanceof.internalInterface
6+
count: 1
7+
path: ../tests/PHPStan/Reflection/ReflectionProviderGoldenTest.php
8+
9+
-
10+
message: '''
11+
#^Call to deprecated method assertFileNotExists\(\) of class PHPUnit\\Framework\\Assert\:
12+
https\://github\.com/sebastianbergmann/phpunit/issues/4077$#
13+
'''
14+
identifier: staticMethod.deprecated
15+
count: 1
16+
path: ../src/Testing/LevelsTestCase.php

build/phpstan.neon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ parameters:
2626
excludePaths:
2727
- ../tests/*/data/*
2828
- ../tests/tmp/*
29+
- ../tests/vendor/*
2930
- ../tests/PHPStan/Analyser/nsrt/*
3031
- ../tests/PHPStan/Analyser/traits/*
3132
- ../tests/notAutoloaded/*

composer.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"react/promise": "^3.2",
3939
"react/socket": "^1.3",
4040
"react/stream": "^1.1",
41-
"sebastian/diff": "^4.0",
41+
"sebastian/diff": "^5.0",
4242
"symfony/console": "^5.4.3",
4343
"symfony/finder": "^5.4.3",
4444
"symfony/polyfill-intl-grapheme": "^1.23",
@@ -55,14 +55,13 @@
5555
"symfony/polyfill-php73": "*"
5656
},
5757
"require-dev": {
58-
"brianium/paratest": "^6.5",
5958
"cweagans/composer-patches": "^1.7.3",
6059
"php-parallel-lint/php-parallel-lint": "^1.2.0",
6160
"phpstan/phpstan-deprecation-rules": "^2.0.2",
6261
"phpstan/phpstan-nette": "^2.0",
63-
"phpstan/phpstan-phpunit": "^2.0",
62+
"phpstan/phpstan-phpunit": "^2.0.7",
6463
"phpstan/phpstan-strict-rules": "^2.0",
65-
"phpunit/phpunit": "^9.6",
64+
"phpunit/phpunit": "10.5.31",
6665
"shipmonk/composer-dependency-analyser": "^1.5",
6766
"shipmonk/dead-code-detector": "^0.12.0",
6867
"shipmonk/name-collision-detector": "^2.0"

0 commit comments

Comments
 (0)