-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
RFC: Refactoring to support PHPUnit 10 #21
Comments
Thanks for looking into this. When I saw that several methods were marked as final I knew this library was going to require some refactoring. Using the event system sounds like a logical replacement, so please do start a branch. 😊 |
I looked into the PHPUnit 10 Extension system and it is not suitable for our needs moving to PHPUnit 10. All Exceptions thrown in an Extension are caught by PHPUnit and silently eaten. I put together a small spike showing an exception getting thrown in the EventLoop during a test case and tests continuing to run with no problem. https://github.com/cspray/amp-phpunit10-example Have some other ideas on how to accomplish this. Will post more updates soon(ish). |
@cspray do you have an update on this? |
@dinamic Unfortunately, I don't. Had a bunch of personal stuff happen in 2023 and I had very little time to devote to Amp related work. The only thing I remember off-hand is that the Extension system is not suitable. I vaguely recall there being some other method that we could potentially hook into, perhaps in some non-API compliant way (i.e. using Reflection on some PHPUnit internals) but that's only a vague recollection. Over the last couple weeks I started working on an Amp-based app and had a need to actually use a |
Would also like to point out #22 where a solution appears to have been found that will keep this working for PHPUnit 10. Given the changes appears to be relatively low risk. |
I did some more looking into this. I do believe that #22 is the appropriate way to support PHPUnit 10. I implemented these changes and used them in a fairly comprehensive test suite and everything worked as I expected it to. I decided to see what these changes would look like with PHPUnit 11 and that failed. In 11.0 I contend this is more evidence that at some point PHPUnit will no longer be a suitable tool for this type of testing. Once PHPUnit 10 is no longer suitable for use I suspect we'll have to start thinking about alternative solutions or come up with something far more clever than our current implementation. For the purpose of this issue however, I would tie the merging of #22 to closing this as I see that the proper solution. |
PHPUnit 10 has recently been released and it includes improvements to the testing framework along with a new Event system. Unfortunately, it also brings along a breaking change that causes this library to no longer work. Specifically, the
PHPUnit\Framework\TestCase::setName
method has been marked as final and can no longer be overridden. Fortunately, I believe the event system could simplify what we'd have to do.A tl;dr is that we create an
Extension
that invokesEventLoop::getSuspension()->suspend()
in an appropriate event. The first thought is thePHPUnit\Event\Events\Test\Finished
event.If this sounds like a good place to start I can work on a new branch for PHPUnit 10 support in the next week or two.
The text was updated successfully, but these errors were encountered: