-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Register Facade Subscribers where state is already global #5204
Register Facade Subscribers where state is already global #5204
Conversation
Codecov Report
@@ Coverage Diff @@
## 10.0 #5204 +/- ##
=========================================
Coverage 84.29% 84.30%
- Complexity 5863 5865 +2
=========================================
Files 635 635
Lines 18578 18588 +10
=========================================
+ Hits 15661 15671 +10
Misses 2917 2917
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
I generally like the idea of decoupling the actual (global) Facade from the individual classes using them - while this PR of course only addresses the registration of Subscribers or Tracers and not the emitting of events. I have two problems with the implementation this PR proposes:
Maybe we can fix these problems somehow? |
Of course we can.
Neither do I. A better approach is to require a
After the aforementioned change, the |
0268da3
to
6e8fae8
Compare
Maybe I am missing where you are headed with this pull request. Can you elaborate why this change would make sense? |
Sure: I'm the maintainer of ParaTest, a tool to support parallel testing in PHPUnit. In order to avoid copy-pasting basically the entire PHPUnit project, I'm re-using a lot of PHPUnit's The most evident friction point is the Singleton classes, or better, an unusal implementation of the Singleton pattern. I would like to be able to use all the Loggers as well, but in the current My goal is here is to keep the current Singletons, as they are not the problem themselves, but to make them decoupled from non-global instances, and also reusable outside the global instance by keeping the constructor public. The benefit for ParaTest is that I can reuse everything PHPUnit already has without mangling its internal state. |
This is certainly heading in the right direction. I'm still having a few smaller issues though. I'm not sure if all got introduced by your changes or have been there to begin with and now only became more obvious. ;) I'll be heading to Montreal for Confoo tomorrow and maybe I'll have some time on the flight to review things a bit more in depth. |
6e8fae8
to
43a653a
Compare
Hi @theseer, have you had the chance to review this? |
@Slamdunk Arne is still on vacation this week, he'll be back next week. I will review your changes together with @theseer and @localheinz no later than March 17-19. |
@Slamdunk Sorry to bother you with this, but with recent changes that I made, this PR now has conflicts that must be resolved. Can you update it? Thanks! |
43a653a
to
f412813
Compare
Done 😉 |
f412813
to
ad1eb97
Compare
Merged manually, thanks! And thanks to @theseer and @localheinz for the joint code review. |
Hi @sebastianbergmann , when merging PR from Github, it keeps tracking of the original PR even in the commit and the GUI: I've seen that when you manually merge some PR, that information gets lost: I find that link very useful to track down the PR and the precious conversation it has. |
I will try to keep that in mind. |
This PR decouples the classes that want to register some
\PHPUnit\Event\Subscriber
from the specific\PHPUnit\Event\Facade
instance in place, the global one.The global instance is now altered (by
Facade::registerSubscribers
,Facade::registerSubscriber
andFacade::registerTracer
) only in:\PHPUnit\TextUI\Application
\PHPUnit\Runner\Extension\Facade
\PHPUnit\TestRunner\TestResult\Facade
\PHPUnit\TextUI\Output\Facade
Which already are single instance by architecture.
All the involved non-Facade classes can now be unit-tested, if neeeded:
\PHPUnit\Logging\JUnit\JunitXmlLogger
\PHPUnit\Logging\TeamCity\TeamCityLogger
\PHPUnit\Logging\TestDox\TestResultCollector
\PHPUnit\Runner\ResultCache\ResultCacheHandler
\PHPUnit\TestRunner\TestResult\Collector
\PHPUnit\TextUI\Output\Default\ProgressPrinter\ProgressPrinter
It is my intention to propose another PR after this one to refactor all Facades to pure Singleton too.