-
Notifications
You must be signed in to change notification settings - Fork 45
Solve the risky test warnings in PHPUnit #89
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
Conversation
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.
Pull Request Overview
This PR addresses PHPUnit’s risky test warnings by integrating Hamcrest assertion counts into PHPUnit and marking tests without assertions to suppress warnings.
- Introduces a reset/Add assertion-count bridge between Hamcrest and PHPUnit in
AbstractMatcherTest - Adds
@doesNotPerformAssertionsto tests that don’t invoke any assertions - Updates child matcher tests to call the new parent setup logic via
parent::setUpTest()
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/Hamcrest/UtilTest.php | Annotated a no-assertion test with @doesNotPerformAssertions |
| tests/Hamcrest/Text/StringStartsWithTest.php | Calls parent::setUpTest() in setUpTest() |
| tests/Hamcrest/Text/StringEndsWithTest.php | Calls parent::setUpTest() in setUpTest() |
| tests/Hamcrest/Text/StringContainsTest.php | Calls parent::setUpTest() in setUpTest() |
| tests/Hamcrest/Text/StringContainsInOrderTest.php | Calls parent::setUpTest() in setUpTest() |
| tests/Hamcrest/Text/StringContainsIgnoringCaseTest.php | Calls parent::setUpTest() in setUpTest() |
| tests/Hamcrest/Text/IsEqualIgnoringWhiteSpaceTest.php | Calls parent::setUpTest() in setUpTest() |
| tests/Hamcrest/FeatureMatcherTest.php | Calls parent::setUpTest() in setUpTest() |
| tests/Hamcrest/Core/SetTest.php | Calls parent::setUpTest() in setUpTest() |
| tests/Hamcrest/Core/IsInstanceOfTest.php | Calls parent::setUpTest() in setUpTest() |
| tests/Hamcrest/Core/CombinableMatcherTest.php | Calls parent::setUpTest() in setUpTest() |
| tests/Hamcrest/AbstractMatcherTest.php | Adds @before/@after hooks to reset and add Hamcrest assertion counts and marks two tests with @doesNotPerformAssertions |
Comments suppressed due to low confidence (1)
tests/Hamcrest/AbstractMatcherTest.php:86
- [nitpick] Consider renaming
tearDownTestto PHPUnit’s standardtearDown()(and similarlysetUpTesttosetUp()) to follow conventions and improve clarity instead of relying solely on annotation hooks.
protected function tearDownTest()
pscheit
left a comment
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.
yeah, this looks good!
This is a valid Co-Pilot comment though ;) before: after: imho this is a well-known convention when using phpunit. |
In restrospective it isn't considering, that method signatures in PHPUnit built-in methods change overtime and to support newer PHPUnit versions we constantly need to adjust ours as well :( |
|
After the native :void was added they were pretty stable |
|
Let's keep it simple in this PR. We can always return to this topic to perform library-wide rename. |
|
yeah, I wasnt referring to that. Totally on your side keeping the PRs small and tidy. Just sometimes it's just impossible to do so :) |
Solves the same problem as #72 , but in different way using my own recommendations in that PR:
@doesNotPerformAssertionsannotation.