PHPUnit 10: allow multiple Application runs
Fixes https://github.com/sebastianbergmann/phpunit/issues/4993
Goal
Make static dependencies explicit and remove Singleton-like behaviours
What this PR does
- Adds a test for https://github.com/sebastianbergmann/phpunit/issues/4993 (link: https://github.com/sebastianbergmann/phpunit/pull/4996/files#diff-24645a564406e6eeec905825aedb7665ec71517813988160be0db72ef294a5a5)
- Removes
staticbehaviour of\PHPUnit\Event\Facade - Removes
staticbehaviour of\PHPUnit\TestRunner\TestResult\Facade - Removes
staticbehaviour of\PHPUnit\Util\Error\Handler - Pass the three above mentioned classes as constructor or method argument where needed
- Adds a new
@internalattribute\PHPUnit\Framework\Assert::$eventFacade, which must bestaticin order to have it working with\PHPUnit\Framework\Assert::assertThat
What this PR does not
This PR doesn't go further with refactoring, as this should be discussed before committing time to it.
For example:
- Now
\PHPUnit\TestRunner\TestResult\Facadeis basically useless, we could directly pass\PHPUnit\TestRunner\TestResult\Collectoraround - Is the change to
\PHPUnit\Framework\Test::runacceptable? I don't answer this question, I simply put evident that both Facades are a dependency for its proper usage
Codecov Report
Merging #4996 (dbc1bc2) into main (6159537) will increase coverage by
0.00%. The diff coverage is92.88%.
@@ Coverage Diff @@
## main #4996 +/- ##
=========================================
Coverage 81.99% 81.99%
+ Complexity 5701 5693 -8
=========================================
Files 579 579
Lines 14942 14946 +4
=========================================
+ Hits 12251 12255 +4
Misses 2691 2691
| Impacted Files | Coverage Δ | |
|---|---|---|
| src/Event/Facade.php | 75.55% <73.52%> (-4.08%) |
:arrow_down: |
| src/TextUI/TestRunner.php | 54.60% <79.31%> (+0.91%) |
:arrow_up: |
| src/Util/PHP/AbstractPhpProcess.php | 80.58% <85.71%> (ø) |
|
| src/Framework/TestRunner.php | 83.56% <88.23%> (+0.15%) |
:arrow_up: |
| src/Runner/TestResult/Facade.php | 93.75% <93.75%> (-0.70%) |
:arrow_down: |
| src/Framework/TestSuite.php | 88.01% <96.15%> (+0.09%) |
:arrow_up: |
| src/Framework/TestCase.php | 86.17% <97.82%> (+0.03%) |
:arrow_up: |
| src/Framework/Assert.php | 91.17% <100.00%> (ø) |
|
| src/Framework/TestBuilder.php | 86.13% <100.00%> (+0.13%) |
:arrow_up: |
| src/Logging/JUnit/JunitXmlLogger.php | 96.71% <100.00%> (+0.02%) |
:arrow_up: |
| ... and 10 more |
:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more
Thank you for working on this, Filippo! As soon as I am done with my current task (migrating the result printer away from Framework\TestResult and getting rid off Framework\TestResult in the process) I will review this.
Unfortunately, now that I would be able to review this pull request it has conflicts that need to be resolved. Can you update the pull request, please? Thanks!
Sure
What is going on here https://github.com/sebastianbergmann/phpunit/runs/8036534281?check_suite_focus=true#step:8:60
OK, but some tests have issues!
Tests: 2606, Assertions: 6555, Warnings: 5.
Error: Process completed with exit code 1.
The issue is in my PR, but I'm still stoned by the feedback
@sebastianbergmann Ready for review
PR rebased after https://github.com/sebastianbergmann/phpunit/commit/12340577a2719266b7072f3036db7488a00ff05c simplification
Thank you for your contribution. I appreciate the time you invested in preparing this pull request. However, I have decided not to merge it, please see https://github.com/sebastianbergmann/phpunit/issues/4993#issuecomment-1240316977 for details.