Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 1.x #155 +/- ##
============================================
+ Coverage 97.48% 97.57% +0.08%
- Complexity 522 550 +28
============================================
Files 65 68 +3
Lines 1432 1483 +51
============================================
+ Hits 1396 1447 +51
Misses 36 36
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
0949953 to
836afe2
Compare
836afe2 to
e87a4f0
Compare
| } | ||
| }); | ||
|
|
||
| $facade->registerSubscriber(new class($reader) implements SkippedSubscriber { |
There was a problem hiding this comment.
If a test method has #[WithEntityChangePurging] and setUp() calls markTestIncomplete(), the static override remains true. PHPUnit does not emit Finished in this case, so the next test without the attribute also has purging enabled, even though the configured default is false.
Reproduced on PHPUnit 12.5.35 and 13.3.3. Adding a MarkedIncompleteSubscriber that calls resetForTest() fixes the issue. This also needs a regression test that checks the switch state in an unannotated test following the incomplete setup.
|
|
||
| public function notify(BeforeTestMethodErrored $event): void | ||
| { | ||
| PurgatoryExtension::resetForTestClass($event->testClassName(), $this->reader); |
There was a problem hiding this comment.
In PHPUnit 13, BeforeTestMethodErrored no longer has a testClassName() method. The interface_exists() guard passes, but when setUp() throws an exception, this subscriber produces an additional runner warning:
Call to undefined method
PHPUnit\Event\Test\BeforeTestMethodErrored::testClassName()
The subsequent ErroredSubscriber still resets the switch, so this reproduction does not leak state. However, the callback fails and adds a warning alongside the original setup error.
Replacing the call with $event->calledMethod()->className() fixes the issue, verified on PHPUnit 12.5.35 and 13.3.3. A regression test exercising the actual setup-error lifecycle would catch this difference between PHPUnit versions.
Summary 📝
This PR adds support for disabling entity change purging by default and enabling it only where needed.
Generating purge requests on every flush can noticeably slow down large test suites, even though most tests never assert on them.
A new
entity_change_purgingconfiguration option can be used to disable this behavior, for example in the test environment:A new PHPUnit extension and
#[WithEntityChangePurging]attribute can then be used to enable purging only for specific test classes or methods:When used on a test class, entity change purging is enabled for all tests in that class. When used on a test method, it is enabled only for that test. In both cases, the configured default is restored afterwards.
The new
EntityChangePurgeSwitchercan also be used directly through itsenable(),disable()andreset()methods, for example to temporarily disable purging while loading fixtures.Checklist ✅