You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bug #60484 [PhpUnitBridge] Clean up mocked features only when @group is present (HypeMC)
This PR was merged into the 7.2 branch.
Discussion
----------
[PhpUnitBridge] Clean up mocked features only when ``@group`` is present
| Q | A
| ------------- | ---
| Branch? | 7.2
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Issues | -
| License | MIT
PR #60174 introduced a bug for tests that don't use the ``@group`` annotation but register mocks manually, e.g. in `setUpBeforeClass`:
```php
class ExampleTest extends TestCase
{
public static function setUpBeforeClass(): void
{
ClockMock::register(self::class);
ClockMock::withClockMock(strtotime('2024-05-20 15:30:00'));
}
public static function tearDownAfterClass(): void
{
ClockMock::withClockMock(false);
}
public function testDate()
{
self::assertSame('2024-05-20 15:30:00', date('Y-m-d H:i:s'));
}
public function testTime()
{
self::assertSame(1716219000, time());
}
}
```
`testDate` passes, but after that `FinishedSubscriber` is triggered which cleans up the mock and causes `testTime` to fail.
I am not sure what to do about `BeforeTestMethodErroredSubscriber` since the test object is not available in that event. I think it's fine to leave it as is.
cc `@xabbuh`
Commits
-------
ea204b9 [PhpUnitBridge] Clean up mocked features only when group is present
0 commit comments