phpunit icon indicating copy to clipboard operation
phpunit copied to clipboard

PHPUnit 10: allow multiple Application runs

Open Slamdunk opened this issue 3 years ago • 2 comments

Fixes https://github.com/sebastianbergmann/phpunit/issues/4993

Goal

Make static dependencies explicit and remove Singleton-like behaviours

What this PR does

  1. Adds a test for https://github.com/sebastianbergmann/phpunit/issues/4993 (link: https://github.com/sebastianbergmann/phpunit/pull/4996/files#diff-24645a564406e6eeec905825aedb7665ec71517813988160be0db72ef294a5a5)
  2. Removes static behaviour of \PHPUnit\Event\Facade
  3. Removes static behaviour of \PHPUnit\TestRunner\TestResult\Facade
  4. Removes static behaviour of \PHPUnit\Util\Error\Handler
  5. Pass the three above mentioned classes as constructor or method argument where needed
  6. Adds a new @internal attribute \PHPUnit\Framework\Assert::$eventFacade, which must be static in 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:

  1. Now \PHPUnit\TestRunner\TestResult\Facade is basically useless, we could directly pass \PHPUnit\TestRunner\TestResult\Collector around
  2. Is the change to \PHPUnit\Framework\Test::run acceptable? I don't answer this question, I simply put evident that both Facades are a dependency for its proper usage

Slamdunk avatar Jun 27 '22 09:06 Slamdunk

Codecov Report

Merging #4996 (dbc1bc2) into main (6159537) will increase coverage by 0.00%. The diff coverage is 92.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

codecov[bot] avatar Jun 27 '22 10:06 codecov[bot]

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.

sebastianbergmann avatar Jul 04 '22 16:07 sebastianbergmann

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!

sebastianbergmann avatar Aug 26 '22 08:08 sebastianbergmann

Sure

Slamdunk avatar Aug 26 '22 08:08 Slamdunk

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

Slamdunk avatar Aug 26 '22 12:08 Slamdunk

@sebastianbergmann Ready for review

Slamdunk avatar Aug 26 '22 14:08 Slamdunk

PR rebased after https://github.com/sebastianbergmann/phpunit/commit/12340577a2719266b7072f3036db7488a00ff05c simplification

Slamdunk avatar Aug 29 '22 06:08 Slamdunk

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.

sebastianbergmann avatar Sep 08 '22 07:09 sebastianbergmann