Skip to content

run tests using PHPUnit 11.5 #58370

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 1 commit into from
Aug 1, 2025

Conversation

xabbuh
Copy link
Member

@xabbuh xabbuh commented Sep 24, 2024

Q A
Branch? 7.4
Bug fix? no
New feature? no
Deprecations? no
Issues
License MIT

@xabbuh
Copy link
Member Author

xabbuh commented Sep 24, 2024

The PR cannot be merged at the moment as it is based on a bunch of other open pull requests that are paving the way to be able to actually run the tests with PHPUnit 11.

@xabbuh xabbuh force-pushed the phpunit11-integration-tests branch 2 times, most recently from 7178ae5 to 76245c5 Compare September 24, 2024 07:31
@alexandre-daubois
Copy link
Member

This is super nice news! Did you already take care of everything required to be "PHPUnit 11 compliant" in already opened PRs ?

@xabbuh
Copy link
Member Author

xabbuh commented Sep 24, 2024

@alexandre-daubois The "ensure session storages are opened before destroying them" commit is the only one that is not already part of an open PR. I do not really understand yet why that change is necessary (the flow in AbstractSessionHandler is different as headers_sent() returns a different result).

@xabbuh xabbuh force-pushed the phpunit11-integration-tests branch from 76245c5 to 24d86e8 Compare September 24, 2024 11:18
@xabbuh xabbuh requested a review from chalasr as a code owner September 24, 2024 11:18
nicolas-grekas added a commit that referenced this pull request Sep 25, 2024
This PR was merged into the 5.4 branch.

Discussion
----------

Tweak error/exception handler registration

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        | Fix #53812
| License       | MIT

This should allow removing the custom bootstrap file from #58370 /cc `@xabbuh`

The change on FrameworkBundle leads to a tweaked behavior: we don't override the previous error handler in case it's not the Symfony one. This shouldn't change anything in practice since the error handler is already registered by the runtime component.

The rest is closer to bug fixes.

Commits
-------

af9c035 Tweak error/exception handler registration
@nicolas-grekas
Copy link
Member

We need a way to register DebugClassLoader, and maybe a few other things. Basically what we do in SymfonyTestsListenerTrait.

@xabbuh xabbuh force-pushed the phpunit11-integration-tests branch 2 times, most recently from ab2f604 to e56f932 Compare September 25, 2024 16:42
@xabbuh xabbuh changed the title run integration tests using PHPUnit 11 [WIP] run integration tests using PHPUnit 11 Sep 27, 2024
@xabbuh xabbuh force-pushed the phpunit11-integration-tests branch from e56f932 to bddc3f5 Compare September 27, 2024 11:30
@xabbuh xabbuh force-pushed the phpunit11-integration-tests branch 5 times, most recently from d72eadc to c89477a Compare October 10, 2024 06:49
@xabbuh xabbuh changed the title [WIP] run integration tests using PHPUnit 11 run integration tests using PHPUnit 11 Oct 10, 2024
@xabbuh xabbuh changed the title run integration tests using PHPUnit 11 [WIP] run integration tests using PHPUnit 11 Oct 10, 2024
fabpot added a commit that referenced this pull request Jul 4, 2025
…fore (xabbuh)

This PR was merged into the 7.2 branch.

Discussion
----------

[HttpClient] return early if handle has been cleaned up before

| Q             | A
| ------------- | ---
| Branch?       | 7.2
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        |
| License       | MIT

When a request has been cleaned up by the PHP process there still can be an event that will later on try to generate the response. Previously this lead to a warning like `Undefined array key "bg"`.

spotted in #58370 where this makes the test fail with PHPUnit 11.5: https://github.com/symfony/symfony/actions/runs/16051022174/job/45293445147#step:9:3827

Commits
-------

fb4711b return early if handle has been cleaned up before
@xabbuh xabbuh force-pushed the phpunit11-integration-tests branch 8 times, most recently from 022669a to 502d029 Compare July 29, 2025 09:49
@xabbuh xabbuh force-pushed the phpunit11-integration-tests branch 4 times, most recently from 89953f7 to 5922e42 Compare July 31, 2025 08:10
Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Impressive work!

@@ -222,7 +222,7 @@ jobs:
echo "::group::install phpunit"
./phpunit install
echo "::endgroup::"
echo "$PATCHED_COMPONENTS" | parallel -j +3 "_run_tests {} 'cd {} && rm composer.lock vendor/ -Rf && $COMPOSER_UP && $PHPUNIT$LEGACY'" || X=1
echo "$PATCHED_COMPONENTS" | parallel -j +3 "_run_tests {} 'cd {} && rm composer.lock vendor/ -Rf && $COMPOSER_UP && $PHPUNIT --exclude-group tty,benchmark,intl-data,integration,transient,legacy'" || X=1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no repeated --exclude-group here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this job uses the PhpUnitBridge from the 6.4 branch which will use PHPUnit 9.6 where we need to pass groups like this: https://github.com/symfony/symfony/actions/runs/16643576218/job/47099900084?pr=58370#step:9:14680

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which also means that we need to update this line for the 8.x lifecycle after merging up

"symfony/http-kernel": "^6.4|^7.0|^8.0",
"symfony/framework-bundle": "^6.4.13|^7.1.6|^8.0",
"symfony/http-kernel": "^6.4.13|^7.1.6|^8.0",
"symfony/runtime": "^6.4.13|^7.1.6|^8.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why adding runtime?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need #58372, otherwise tests fail like this with low deps:

PHPUnit 11.5.28 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.2.29
Configuration: /home/runner/work/symfony/symfony/src/Symfony/Bridge/PsrHttpMessage/phpunit.xml.dist

...........................RRR........                            38 / 38 (100%)

Time: 00:00.163, Memory: 28.00 MB

There were 3 risky tests:

1) Symfony\Bridge\PsrHttpMessage\Tests\Functional\ControllerTest::testServerRequestAction
Test code or tested code did not remove its own exception handlers

/home/runner/work/symfony/symfony/src/Symfony/Bridge/PsrHttpMessage/Tests/Functional/ControllerTest.php:22

2) Symfony\Bridge\PsrHttpMessage\Tests\Functional\ControllerTest::testRequestAction
Test code or tested code did not remove its own exception handlers

/home/runner/work/symfony/symfony/src/Symfony/Bridge/PsrHttpMessage/Tests/Functional/ControllerTest.php:31

3) Symfony\Bridge\PsrHttpMessage\Tests\Functional\ControllerTest::testMessageAction
Test code or tested code did not remove its own exception handlers

/home/runner/work/symfony/symfony/src/Symfony/Bridge/PsrHttpMessage/Tests/Functional/ControllerTest.php:40

OK, but there were issues!
Tests: 38, Assertions: 260, PHPUnit Deprecations: 4, Risky: 3.
Job exited with: 1

@xabbuh xabbuh force-pushed the phpunit11-integration-tests branch from 5922e42 to 6f6b5fe Compare July 31, 2025 09:26
@xabbuh xabbuh force-pushed the phpunit11-integration-tests branch from 6f6b5fe to 652ba2e Compare July 31, 2025 09:37
Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@nicolas-grekas
Copy link
Member

Thank you @xabbuh.

@nicolas-grekas nicolas-grekas merged commit 53e759a into symfony:7.4 Aug 1, 2025
13 checks passed
@xabbuh xabbuh deleted the phpunit11-integration-tests branch August 1, 2025 16:21
@OskarStark
Copy link
Contributor

Many thanks 🙌❤️

@derrabus
Copy link
Member

derrabus commented Aug 1, 2025

No way! Thanks @xabbuh for getting this one over the finish line!

@wouterj
Copy link
Member

wouterj commented Aug 2, 2025

You did it!! This was a massive effort. Thanks a lot @xabbuh! 💚

nicolas-grekas added a commit that referenced this pull request Aug 21, 2025
…ionMessage() method (xabbuh)

This PR was merged into the 7.4 branch.

Discussion
----------

[HttpFoundation] use PHPUnit's native expectUserDeprecationMessage() method

| Q             | A
| ------------- | ---
| Branch?       | 7.4
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Issues        |
| License       | MIT

In #58370 I rewrote the tests in `NativeSessionStorageTest` to work around a bug in PHPUnit that didn't allow to have assertions about deprecations triggered in tests that were run in separate processes. Thanks to sebastianbergmann/phpunit#6283 (available in e.g. PHPUnit 12.3.5+) we don't need this workaround anymore.

Commits
-------

c7b14f8 use PHPUnit's native expectUserDeprecationMessage() method
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.