-
-
Notifications
You must be signed in to change notification settings - Fork 166
Ignore switch(bool) statements in TrueValue and FalseValue mutators. #1986
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
NOTE: The test cases could probably use particular attention. My test cases are asserting that switch statements are NOT mutated. I am not familiar with the Infection codebase, and could not find equivalent test cases or assertions to base mine upon, so it may or may not need massaging. All test cases behave as I would expect, otherwise. Here, specifically, is how I have accomplished this assertion: infection/src/Testing/BaseMutatorTestCase.php Lines 116 to 123 in e7aa2fd
|
PHP; | ||
|
||
$this->assertInputNotMutated($inputCode); | ||
} |
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.
actually, you don't need to create separate method to test the case when no mutation is happening.
Please, look here to get an example:
infection/tests/phpunit/Mutator/Boolean/FalseValueTest.php
Lines 74 to 81 in a663d6c
yield 'It does not mutate the string false to true' => [ | |
<<<'PHP' | |
<?php | |
return 'false'; | |
PHP | |
, | |
]; |
so you basically need to create the same yield
with switch (false)
. Thus, new created method assertInputNotMutated
can also be removed
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.
Looks good, thanks. After tests are fixed, happy to merge it
Head branch was pushed to by a user without write access
Thanks for the feedback @maks-rafalko. I had a feeling there was a better way... |
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.
Thank you @shanept
This PR:
Fixes #819
This will stop false positives related to boolean values in switch conditions, where no code coverage has been detected.