-
Notifications
You must be signed in to change notification settings - Fork 168
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
Internal: Fix PHPUnit deprecated prophecy integration #3190
Conversation
Thanks for contributing towards Open Social! A maintainer from the @goalgorilla/maintainers group might not review all changes from all teams/contributors. Please don't be discouraged if it takes a while. In the meantime, we have some automated checks running and it might be that you will see our comments with some tips or requests to speed up the review process. 😊 |
643f82a
to
47517e6
Compare
protected function tearDown(): void { | ||
$this->prophet->checkPredictions(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it a good idea to do this in tear down rather than on a per-test basis? I'm not sure how reporting will differ ("There was an error in cleaning up" vs "Your test failed").
I.e. the underlying question is: Does PHPUnit already consider the test case a success if it performs tearDown? If the answer is yes, we should move this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Alexander,
Is it a good idea to do this in tear down rather than on a per-test basis? I'm not sure how reporting will differ ("There was an error in cleaning up" vs "Your test failed").
According to https://phpunit.readthedocs.io/en/9.5/fixtures.html#fixtures setUp()
and tearDown()
template methods are run once for each test method (and on fresh instances) of the test case class. and Example Example 4.2 has a nice explanation on how they work.
I.e. the underlying question is: Does PHPUnit already consider the test case a success if it performs tearDown? If the answer is yes, we should move this.
According to official documentation from prophecy tearDown()
is where we should call checkPredictions()
Please check here for more information: https://github.com/phpspec/prophecy#predictions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If official documentation says it, then that's good enough for me 👍
Cherry-picked to 11.5.x here 5c464c4 |
Problem
PHPUnit deprecated prophecy integration on sebastianbergmann/phpunit#4141
Solution
There a couple of approaches, all suggested on the above PR:
Use prophecy directly, suggested here Deprecate Prophecy integration sebastianbergmann/phpunit#4141 (comment)
Use a rector suggested here Deprecate Prophecy integration sebastianbergmann/phpunit#4141 (comment)
Whatever the method, unit tests should still work.
Issue tracker
N/A
Theme issue tracker
N/A
How to test
Definition of done
Before merge
After merge
Screenshots
N/A
Release notes
N/A
Change Record
N/A
Translations
N/A