-
Notifications
You must be signed in to change notification settings - Fork 110
Setup mutation testing #686
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
+144
−0
Merged
Changes from 50 commits
Commits
Show all changes
52 commits
Select commit
Hold shift + click to select a range
8a4e7cd
Setup mutation testing
staabm 65db2c8
Update platform-test.yml
staabm d3a6e60
fix built
staabm 69b69ca
fix build
staabm baab8a3
run infection in all test jobs
staabm b44bb9c
Update platform-test.yml
staabm d223186
Update platform-test.yml
staabm 843fbfe
Update platform-test.yml
staabm 7a2ece5
Update platform-test.yml
staabm 788a450
cs
staabm 7517bac
Update platform-test.yml
staabm 0cf3164
Update platform-test.yml
staabm 811f79d
Update build.yml
staabm cf457bb
Discard changes to .github/workflows/platform-test.yml
staabm 547569a
Update build.yml
staabm ba0c6b8
Update TrinaryLogicMutator.php
staabm bcc667f
Update build.yml
staabm 6075749
feedback
staabm 71c74c4
Update build.yml
staabm c180a99
Update build.yml
staabm ae2e5ff
Cannot pass both "--git-diff-lines" and "--git-diff-filter" options
staabm e680440
Update DoctrineTypeUtils.php
staabm 1398077
Update composer.json
staabm d1637c4
Update QueryBuilderDqlRule.php
staabm 80978eb
Update DoctrineTypeUtils.php
staabm 054bb5e
Update build.yml
staabm 2ae9a03
Update QueryBuilderDqlRule.php
staabm fb3db22
Update infection.json5
staabm c37fc3f
Update build.yml
staabm 871cd46
Update build.yml
staabm 7e0fd4a
Update infection.json5
staabm 946fc28
Update phpstan.neon
staabm e509b9a
Update build.yml
staabm 2eecbb9
use local temp
staabm 704bce2
unique artifact name
staabm 19706cb
Update build.yml
staabm 2caea8d
Update build.yml
staabm 9f9de8f
fix
staabm c4d823e
Update infection.json5
staabm 93d3d97
Update infection.json5
staabm 01a9197
Update infection.json5
staabm 58e765a
simplify
staabm 378e518
increase timeout
staabm b3b8b99
Update infection.json5
staabm 67cf382
upload infection log as artifact to ease debugging
staabm c0e5252
Update build.yml
staabm d954a45
enable debugging
staabm 13ad641
pin infection version
staabm 3bddff7
update to infection:0.31.3
staabm 91d8b14
pin infection:0.31.4
staabm 60f5abd
always upload infection.log
staabm 34a70de
Discard changes to src/Rules/Doctrine/ORM/QueryBuilderDqlRule.php
staabm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"$schema": "vendor/infection/infection/resources/schema.json", | ||
"timeout": 30, | ||
"source": { | ||
"directories": [ | ||
"src" | ||
] | ||
}, | ||
"staticAnalysisTool": "phpstan", | ||
"logs": { | ||
"text": "tmp/infection.log" | ||
}, | ||
"mutators": { | ||
"@default": false, | ||
"PHPStan\\Infection\\TrinaryLogicMutator": true | ||
} | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace PHPStan\Infection; | ||
|
||
use Infection\Mutator\Definition; | ||
use Infection\Mutator\Mutator; | ||
use Infection\Mutator\MutatorCategory; | ||
use LogicException; | ||
use PhpParser\Node; | ||
use function in_array; | ||
|
||
/** | ||
* @implements Mutator<Node\Expr\MethodCall> | ||
*/ | ||
final class TrinaryLogicMutator implements Mutator | ||
{ | ||
|
||
public static function getDefinition(): Definition | ||
{ | ||
return new Definition( | ||
<<<'TXT' | ||
Replaces TrinaryLogic->yes() with !TrinaryLogic->no() and vice versa. | ||
TXT | ||
, | ||
MutatorCategory::ORTHOGONAL_REPLACEMENT, | ||
null, | ||
<<<'DIFF' | ||
- $type->isBoolean()->yes(); | ||
+ !$type->isBoolean()->no(); | ||
DIFF, | ||
); | ||
} | ||
|
||
public function getName(): string | ||
{ | ||
return 'TrinaryLogicMutator'; | ||
} | ||
|
||
public function canMutate(Node $node): bool | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. atm this class replaces any call to a method named There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
{ | ||
if (!$node instanceof Node\Expr\MethodCall) { | ||
return false; | ||
} | ||
|
||
if (!$node->name instanceof Node\Identifier) { | ||
return false; | ||
} | ||
|
||
if (!in_array($node->name->name, ['yes', 'no'], true)) { | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
public function mutate(Node $node): iterable | ||
{ | ||
if (!$node->name instanceof Node\Identifier) { | ||
throw new LogicException(); | ||
} | ||
|
||
if ($node->name->name === 'yes') { | ||
yield new Node\Expr\BooleanNot(new Node\Expr\MethodCall($node->var, 'no')); | ||
} else { | ||
yield new Node\Expr\BooleanNot(new Node\Expr\MethodCall($node->var, 'yes')); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.
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.
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.
Phpunit killer requires a green test run
Phpstan killer requires a green phpstan run