Skip to content

PHPUnit 10 #4046

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

Merged
merged 16 commits into from
Jun 7, 2025
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: 5 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,15 @@ jobs:
coverage: "none"
php-version: "${{ matrix.php-version }}"

- name: "Downgrade PHPUnit"
if: matrix.php-version == '7.4' || matrix.php-version == '8.0'
run: "composer require --dev phpunit/phpunit:^9.6 sebastian/diff:^4.0 --update-with-dependencies --ignore-platform-reqs"

- name: "Install dependencies"
run: "composer install --no-interaction --no-progress"

- name: "Transform source code"
if: matrix.php-version != '8.1' && matrix.php-version != '8.2' && matrix.php-version != '8.3' && matrix.php-version != '8.4'
if: matrix.php-version == '7.4' || matrix.php-version == '8.0'
run: |
composer install --no-interaction --no-progress --working-dir=compiler
./compiler/vendor/bin/simple-downgrade downgrade -c build/downgrade.php ${{ matrix.php-version }}
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/phar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ jobs:
- name: "Install dependencies"
run: "composer install --no-interaction --no-progress"

# only sebastian/diff ^4 supports PHP 7.4 so we need that in the PHAR
- name: "Downgrade PHPUnit"
run: "composer require --dev phpunit/phpunit:^9.6 sebastian/diff:^4.0 --update-with-dependencies --ignore-platform-reqs"

- name: "Install compiler dependencies"
run: "composer install --no-interaction --no-progress --working-dir=compiler"

Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/reflection-golden-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ jobs:
run: "composer install --no-interaction --no-progress"

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

- name: "Downgrade PHPUnit"
if: matrix.php-version == '7.4' || matrix.php-version == '8.0'
run: "composer require --dev phpunit/phpunit:^9.6 sebastian/diff:^4.0 --update-with-dependencies --ignore-platform-reqs"

- name: "Install dependencies"
run: "composer install --no-interaction --no-progress"

- name: "Transform source code"
if: matrix.php-version != '8.1' && matrix.php-version != '8.2' && matrix.php-version != '8.3' && matrix.php-version != '8.4'
if: matrix.php-version == '7.4' || matrix.php-version == '8.0'
run: |
composer install --no-interaction --no-progress --working-dir=compiler
./compiler/vendor/bin/simple-downgrade downgrade -c build/downgrade.php ${{ matrix.php-version }}
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,22 @@ jobs:
ini-file: development
extensions: mbstring

- name: "Downgrade PHPUnit"
if: matrix.php-version == '7.4' || matrix.php-version == '8.0'
shell: bash
run: "composer require --dev phpunit/phpunit:^9.6 sebastian/diff:^4.0 --update-with-dependencies --ignore-platform-reqs"

- name: "Install dependencies"
run: "composer install --no-interaction --no-progress"

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


- name: "PHPStan"
run: "make phpstan"

Expand Down
63 changes: 50 additions & 13 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ jobs:
fail-fast: false
matrix:
php-version:
- "7.4"
- "8.0"
- "8.1"
- "8.2"
- "8.3"
Expand All @@ -57,15 +55,6 @@ jobs:
- name: "Install dependencies"
run: "composer install --no-interaction --no-progress"

- name: "Transform source code"
if: matrix.php-version != '8.1' && matrix.php-version != '8.2' && matrix.php-version != '8.3' && matrix.php-version != '8.4'
shell: bash
run: |
composer install --no-interaction --no-progress --working-dir=compiler
./compiler/vendor/bin/simple-downgrade downgrade -c build/downgrade.php ${{ matrix.php-version }}
composer dump


- name: "Tests"
run: "make tests"

Expand Down Expand Up @@ -118,8 +107,8 @@ jobs:
ini-file: development
ini-values: memory_limit=1G

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

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

- name: "Tests"
run: "${{ matrix.script }}"

tests-with-old-phpunit:
name: "Tests with old PHPUnit"
runs-on: ${{ matrix.operating-system }}
timeout-minutes: 60

strategy:
fail-fast: false
matrix:
php-version:
- "7.4"
- "8.0"
operating-system: [ ubuntu-latest, windows-latest ]

steps:
- name: "Checkout"
uses: actions/checkout@v4

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"
tools: pecl
extensions: ds,mbstring
ini-file: development
ini-values: memory_limit=2G

- name: "Downgrade PHPUnit"
shell: bash
run: "composer require --dev phpunit/phpunit:^9.6 sebastian/diff:^4.0 --update-with-dependencies --ignore-platform-reqs"

- name: "Install dependencies"
run: "composer install --no-interaction --no-progress"

- name: "Downgrade PHPUnit with Paratest"
shell: bash
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"

- name: "Transform source code"
shell: bash
run: |
composer install --no-interaction --no-progress --working-dir=compiler
./compiler/vendor/bin/simple-downgrade downgrade -c build/downgrade.php ${{ matrix.php-version }}
composer dump

- name: "Tests"
run: "make tests"
19 changes: 8 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,14 @@

build: cs tests phpstan

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

tests-integration:
php vendor/bin/paratest --runner WrapperRunner --no-coverage --group exec

tests-levels:
php vendor/bin/paratest --runner WrapperRunner --no-coverage --group levels

tests-coverage:
php vendor/bin/paratest --runner WrapperRunner
tests-integration: install-paratest
php tests/vendor/bin/paratest --runner WrapperRunner --no-coverage --group exec

tests-golden-reflection:
php vendor/bin/paratest --runner WrapperRunner --no-coverage tests/PHPStan/Reflection/ReflectionProviderGoldenTest.php
php vendor/bin/phpunit tests/PHPStan/Reflection/ReflectionProviderGoldenTest.php

lint:
XDEBUG_MODE=off php vendor/bin/parallel-lint --colors \
Expand Down Expand Up @@ -113,6 +107,9 @@ lint:
--exclude tests/PHPStan/Rules/Playground/data/promote-missing-override.php \
src tests

install-paratest:
composer install --working-dir tests

cs:
composer install --working-dir build-cs && XDEBUG_MODE=off php build-cs/vendor/bin/phpcs

Expand Down
5 changes: 5 additions & 0 deletions build/ignore-by-php-version.neon.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
$includes[] = __DIR__ . '/deprecated-8.4.neon';
}

if (PHP_VERSION_ID < 80100) {
$includes[] = __DIR__ . '/old-phpunit.neon';
} else {
$includes[] = __DIR__ . '/new-phpunit.neon';
}
$config = [];
$config['includes'] = $includes;

Expand Down
7 changes: 7 additions & 0 deletions build/new-phpunit.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
parameters:
ignoreErrors:
-
message: '#^Call to an undefined static method PHPUnit\\Framework\\TestCase\:\:assertFileNotExists\(\)\.$#'
identifier: staticMethod.notFound
count: 1
path: ../src/Testing/LevelsTestCase.php
16 changes: 16 additions & 0 deletions build/old-phpunit.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
parameters:
ignoreErrors:
-
message: '#^Instanceof references internal interface PHPUnit\\Exception\.$#'
identifier: instanceof.internalInterface
count: 1
path: ../tests/PHPStan/Reflection/ReflectionProviderGoldenTest.php

-
message: '''
#^Call to deprecated method assertFileNotExists\(\) of class PHPUnit\\Framework\\Assert\:
https\://github\.com/sebastianbergmann/phpunit/issues/4077$#
'''
identifier: staticMethod.deprecated
count: 1
path: ../src/Testing/LevelsTestCase.php
1 change: 1 addition & 0 deletions build/phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ parameters:
excludePaths:
- ../tests/*/data/*
- ../tests/tmp/*
- ../tests/vendor/*
- ../tests/PHPStan/Analyser/nsrt/*
- ../tests/PHPStan/Analyser/traits/*
- ../tests/notAutoloaded/*
Expand Down
7 changes: 3 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"react/promise": "^3.2",
"react/socket": "^1.3",
"react/stream": "^1.1",
"sebastian/diff": "^4.0",
"sebastian/diff": "^5.0",
"symfony/console": "^5.4.3",
"symfony/finder": "^5.4.3",
"symfony/polyfill-intl-grapheme": "^1.23",
Expand All @@ -55,14 +55,13 @@
"symfony/polyfill-php73": "*"
},
"require-dev": {
"brianium/paratest": "^6.5",
"cweagans/composer-patches": "^1.7.3",
"php-parallel-lint/php-parallel-lint": "^1.2.0",
"phpstan/phpstan-deprecation-rules": "^2.0.2",
"phpstan/phpstan-nette": "^2.0",
"phpstan/phpstan-phpunit": "^2.0",
"phpstan/phpstan-phpunit": "^2.0.7",
"phpstan/phpstan-strict-rules": "^2.0",
"phpunit/phpunit": "^9.6",
"phpunit/phpunit": "10.5.31",
"shipmonk/composer-dependency-analyser": "^1.5",
"shipmonk/dead-code-detector": "^0.12.0",
"shipmonk/name-collision-detector": "^2.0"
Expand Down
Loading
Loading