Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: Clean-up listener/subscriber after the test #78

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
michalbundyra merged 3 commits into master from feat/clean-up-on-tear-down
Mar 12, 2025

Conversation

@michalbundyra
Copy link
Member

@michalbundyra michalbundyra commented Mar 10, 2025
edited
Loading

Fixes #74

Now MockDisabler constructor has optional 2nd parameter callback which will be executed once the test ends.
We remove the listener (for old PHPUnit versions) and for newer - remove the subscriber. It stills heavily relies on the internals of PHPUnit and it might break at any point, but as so the whole package.

Tests are a bit tricky, basically we chain of three tests, so I do not need to register a mock function in set up.
First just register a mock and it should be clearer in tearDown;
so then, the second should have the counter === 1, as the mock has been disabled, and it should be removed at this point, so the 3rd test should remain with the same counter (=== 1) - and actually it was failing before before the 'callback' solution.

Copy link
Member Author

@mvorisek, I was able to replicate the issue, and I believe it should be resolved here.
It was a bit tricky to test it. Any feedback will be very appreciated! Thanks

@michalbundyra michalbundyra added this to the 2.12.0 milestone Mar 10, 2025
@michalbundyra michalbundyra marked this pull request as ready for review March 10, 2025 19:33
@michalbundyra michalbundyra merged commit 17f68c1 into master Mar 12, 2025
128 checks passed
@michalbundyra michalbundyra deleted the feat/clean-up-on-tear-down branch March 12, 2025 15:12
Copy link
Member Author

@mvorisek - thanks, 2.12.0 is now released.

mvorisek reacted with heart emoji

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

2.12.0

Development

Successfully merging this pull request may close these issues.

registerForTearDown must remove PHPUnit listener once disable is called

2 participants

AltStyle によって変換されたページ (->オリジナル) /