-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
[PHPUnit bridge] Support for PHPUnit 11.1+ #49069
Comments
I should add that those events are triggered through an error handler, and that having the bridge installed actively breaks it. Maybe we should disable (and later disband) that feature under PHPUnit 10+? |
Well, I don't think PHPUnit 10 contains the existing deprecation-related features of the bridge (at least not all of them). However, we should look at rebuilding them on top of the PHPUnit events instead of replacing the error handler with our own for PHPUnit 10+. |
I discussed PHPUnit 10's event system with @nicolas-grekas at SymfonyCon in November. I think the way forward for Symfony is to no longer register its own error handler for the bridge, let PHPUnit's own error handle emit events for deprecations etc., and then have the bridge subscribe to the events it is interested in. If you want the bridge to produce different output for deprecations than what PHPUnit offers out of the box. |
Do u plan to fix it in 6.3? |
now that PHPUnit 10 is out, I'm giving this a shot. I experience the same error noted here: symfony/recipes#1173 @nicolas-grekas notes here that this should resolve the problem. It looks like that was merged, so I'm wondering what the next step is here. |
Next step would be adding the PHPUnit 10 support to the deprecation handler; this probably means a nearly total rewrite of it, to be done side-by-side to the old one, since the versioning of the bridge is tied to the framework. |
Sounds pretty labor intensive. Would you say this is a priority of the team, or consumers shouldn't expect to see 10 support for quite some time? |
Well, this indeed requires work. Whether this will be done in time for 6.3 depends of when someone works on it (however, it would be great to have it in 6.3 rather than waiting for 6.4 if possible, given that PHPUnit 10 is stable). |
Can we at least consider a quick patch were we completely disable the error handler if we detect PHPUnit 10? As of now, the simple presence of the
I'm even setting [EDIT] Using a real env var fixed it: https://github.com/facile-it/paraunit/actions/runs/4213058997/jobs/7312518640 |
@Jean85 I like your idea! I'd rather be able to stay on a neutered |
@Jean85 are you saying this can be worked around temporarily by setting |
Yes, exactly. The bootstrap of the bridge is loaded through the autoloader, so long before DotEnv or PHPUnit config can kick in. They can still influence the bridge behavior, but the error handler is already registered (and causing the issue) at that point. |
@Jean85 I am unable to reproduce your workaround. I removed when I run
Similar issues when I run
Defining hard env var I'm wondering how you managed to get phpunit 10 working with
|
Yeah I'm not using the test pack, just plain PHPUnit + the bridge. I was using it just for the deprecation helper (and the clock mock). |
hmmm, okay. Maybe I will try that. I was using |
@stof @nicolas-grekas @dunglas i can work on this and submit a PR if you all are interested and have time to review my work. I've done so for symfony panther, though the work still isn't merged: symfony/panther#589 The change log there could be reduced if we get this package phpunit 10 compliant first, as the work there currently requires a workaround the lack of compliance here. Are you all interested? |
There are different tasks on the topic. One of them is ensuring test suites can run on phpunit 10. We've already merged some changes on this topic from @OskarStark and @alexandre-daubois mostly. The first step is running deprecation-free on 9.6. |
Thanks for the info @nicolas-grekas. Would it be helpful for me to start work or hold off until those other items are addressed first? Part of the question is whether we are merely adding support for 10, or also dropping support for some older versions(s) too |
I think we're almost done with deprecations brought by PHPUnit 9.6 on the Symfony code base 🙂 Once that's done, I'll have a look at the bridge if I can also do something to help. @arderyp I think that if you have ideas on how to bring support of PHPUnit 10, you should definitely go ahead! 😄 |
Thanks for the insight @alexandre-daubois. Is there a specific branch I should be working off of? |
@alexandre-daubois @nicolas-grekas will/should 5.4 support phpunit 10? If I work on this, should I be working off the 5.4 branch? I'd certainly like 5.4 to support it. |
Yes, it's clear that it's not always very clear what role bridge, the test pack and the library play in relation to each other. |
Hi, thanks for the update. In latest PHPUnit 11 I still do not find an alternative to the deprecation ignore file. We use it a lot in Drupal. I saw that the Is that planned if you know? FTR, I will close now the MR #50371 |
PHPUnit also has a concept of baseline (in 10.4+): https://docs.phpunit.de/en/11.0/error-handling.html#ignoring-previously-reported-issues |
Yes I saw that, @stof, thanks. I was inquiring on the ignore file since in Drupal we did not implement the baseline, and it will be rather hard to do in our testing framework. |
The plan for the new version of the bridge is to drop all features related to the deprecations, by using the features of PHPUnit. If the current PHPUnit baseline feature is not usable for you, I would suggest discussing that with the PHPUnit team. |
I guess phpunit 11.2 now supports direct/indirect (https://docs.phpunit.de/en/11.2/error-handling.html#limiting-issues-to-your-code) and a baseline therefore we don't need the phpunit bridge anymore this should probably be closed in favor of #53812. |
So will the test-pack drop the bridge component? That would be nice |
…` (derrabus) This PR was merged into the 7.2 branch. Discussion ---------- [PhpUnitBridge] Add `ExpectUserDeprecationMessageTrait` | Q | A | ------------- | --- | Branch? | 7.2 | Bug fix? | no | New feature? | yes | Deprecations? | no | Issues | Part of #49069, replaces #54538 | License | MIT PHPUnit 11 introduces a method `expectUserDeprecationMessage()` which lets us define which deprecation messages we expect the tested code to raise. This new method can replace our own `expectDeprecation()` method once we upgrade to PHPUnit 11. This PR introduces a `ExpectUserDeprecationMessageTrait` that polyfills this method for older PHPUnit versions. This allowed me to run all tests that I've migrated to `expectUserDeprecationMessage()` with PHPUnit 11. Commits ------- 2485e15 [PhpUnitBridge] Add ExpectUserDeprecationMessageTrait
Bridge does many things, and PHPUnit isn't the only part of TestPack. If you'd like to install PHPUnit only, you can do it. You do not have to install the whole TestPack. If I remember right, the original main goal of Bridge was compatibility between tests written atop different PHPUnit versions. Imagine you have a lot of legacy tests in PHPunit (6.x, 7.x, etc.). It would take a while to update them, and there is no guarantee that a bug wouldn't be added. So we need a way to run old tests alongside new ones. |
That is correct. You don't have to install PHPUnit through the bridge if you don't want to. Use PHPUnit 11 and be happy with it. Symfony's own test suite is stuck on PHPUnit 9.6 at the moment, but don't let this stop you. |
Also note that the PHPUnit bridge is not only about the deprecation reporting layer. Once we work on using the PHPUnit native deprecation reporting system on 11.2+, we should provide a version of the bridge supporting its other features on PHPunit 11 |
Let's see what can be done! Mocks should already work with phpunit 11, is there a repository where we could move these and avoid the phpunit 9 dependency lock? For other features I think that most are not useful to Symfony developers but let's see each documented feature.
Not needed anymore, use attributes.
Any idea where to move these?
Not sure why this is needed by Symfony users this should probably stay internal. b. running tests in parallel when a test suite is split in several phpunit.xml files; If you need this you will probably prefer ParaTest or c. recording and replaying skipped tests; I never needed this but there's no equivalent right now as far as I know.
Same as above I think that this is mostly for Symfony tests and it should probably stay internal. |
I don't think that |
There is no dependency lock. You can install the PhpUnitBridge together with PHPUnit 11. Or am I missing something? |
Is there any hope of symfony/phpunit-bridge supporting the newer phpunit versions? |
If you want to work on making ClockMock compatible with PHPUnit 11, please do so. It's not actively being worked on, as far as I know. |
Description
PHPUnit 10 is around the corner (possibly released next month), and it contains a complete overhaul of its internals, particularly the new event system: sebastianbergmann/phpunit#4676
The new system also provides an easy way too hook into those events: https://github.com/sebastianbergmann/phpunit/blob/2a89c3c62c4d94fa92b72cb3693ca4fa057e4517/src/Event/Facade.php#L40
Among the events, there are even multiple dedicated to deprecations:
E_USER_DEPRECATED
: https://github.com/sebastianbergmann/phpunit/blob/main/src/Event/Events/Test/Issue/DeprecationTriggered.phpE_DEPRECATED
: https://github.com/sebastianbergmann/phpunit/blob/main/src/Event/Events/Test/Issue/PhpDeprecationTriggered.phpThis maybe warrants a discussion here on how to tackle this new release, and how to leverage all this new features.
Example
No response
The text was updated successfully, but these errors were encountered: