-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[PhpUnitBridge] properly clean up mocked features after tests have run #60174
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alexandre-daubois
approved these changes
Apr 8, 2025
If a test has been skipped or if it errored, the mocked PHP functions must be cleaned up as well.
77d6b8a
to
9757a69
Compare
Thank you @xabbuh. |
Merged
renovate bot
added a commit
to Runroom/archetype-drupal
that referenced
this pull request
May 6, 2025
This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [symfony/phpunit-bridge](https://symfony.com) ([source](https://redirect.github.com/symfony/phpunit-bridge)) | `7.2.0` -> `7.2.6` | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>symfony/phpunit-bridge (symfony/phpunit-bridge)</summary> ### [`v7.2.6`](https://redirect.github.com/symfony/phpunit-bridge/releases/tag/v7.2.6) [Compare Source](https://redirect.github.com/symfony/phpunit-bridge/compare/v7.2.0...v7.2.6) **Changelog** (symfony/phpunit-bridge@v7.2.5...v7.2.6) - bug [symfony/symfony#60174](https://redirect.github.com/symfony/symfony/issues/60174) \[PhpUnitBridge] properly clean up mocked features after tests have run ([@​xabbuh](https://redirect.github.com/xabbuh)) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/Runroom/archetype-drupal). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS4yNjQuMCIsInVwZGF0ZWRJblZlciI6IjM5LjI2NC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->
nicolas-grekas
added a commit
that referenced
this pull request
May 20, 2025
…p`` 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If a test has been skipped or if it errored, the mocked PHP functions must be cleaned up as well.