Skip to content

Commit

Permalink
skip
Browse files Browse the repository at this point in the history
  • Loading branch information
theofidry committed Apr 11, 2024
1 parent c8cb494 commit 4c1f59f
Show file tree
Hide file tree
Showing 2 changed files with 191 additions and 17 deletions.
8 changes: 7 additions & 1 deletion src/Mutator/Unwrap/UnwrapArrayMap.php
Expand Up @@ -64,7 +64,13 @@ public static function getDefinition(): ?Definition
TXT
,
MutatorCategory::SEMANTIC_REDUCTION,
null,
<<<'TXT'
This mutation escaping suggests that the `$callback` transformation passed to
`array_map()` does no effect to the passed elements.
Either this transformation is needed in which case additional tests capturing
this need are required, or it is not and should be removed.
TXT,
<<<'DIFF'
- $x = array_map($callback, ['foo', 'bar', 'baz']);
+ $x = ['foo', 'bar', 'baz'];
Expand Down
200 changes: 184 additions & 16 deletions tests/phpunit/Mutator/DefinitionTest.php
Expand Up @@ -35,7 +35,9 @@

namespace Infection\Tests\Mutator;

use function array_diff_key;
use function array_fill_keys;
use function array_flip;
use Infection\Mutator\Definition;
use Infection\Mutator\Mutator;
use Infection\Mutator\MutatorCategory;
Expand All @@ -49,6 +51,169 @@
#[CoversClass(Definition::class)]
final class DefinitionTest extends TestCase
{
// TODO: address those
private const MUTATORS_WITHOUT_REMEDIES = [
'Assignment',
'AssignmentEqual',
'BitwiseAnd',
'BitwiseNot',
'BitwiseOr',
'BitwiseXor',
'Decrement',
'DivEqual',
'Division',
'Exponentiation',
'Increment',
'Minus',
'MinusEqual',
'ModEqual',
'Modulus',
'MulEqual',
'Multiplication',
'Plus',
'PlusEqual',
'PowEqual',
'RoundingFamily',
'ShiftLeft',
'ShiftRight',
'ArrayItem',
'EqualIdentical',
'FalseValue',
'IdenticalEqual',
'InstanceOf_',
'LogicalAnd',
'LogicalAndAllSubExprNegation',
'LogicalAndNegation',
'LogicalAndSingleSubExprNegation',
'LogicalLowerAnd',
'LogicalLowerOr',
'LogicalNot',
'LogicalOr',
'LogicalOrAllSubExprNegation',
'LogicalOrNegation',
'LogicalOrSingleSubExprNegation',
'NotEqualNotIdentical',
'NotIdenticalNotEqual',
'TrueValue',
'Yield_',
'GreaterThan',
'GreaterThanOrEqualTo',
'LessThan',
'LessThanOrEqualTo',
'Equal',
'GreaterThanNegotiation',
'GreaterThanOrEqualToNegotiation',
'Identical',
'LessThanNegotiation',
'LessThanOrEqualToNegotiation',
'NotEqual',
'NotIdentical',
'ProtectedVisibility',
'PublicVisibility',
'DecrementInteger',
'IncrementInteger',
'OneZeroFloat',
'AssignCoalesce',
'Break_',
'Coalesce',
'Concat',
'Continue_',
'ElseIfNegation',
'Finally_',
'IfNegation',
'NullSafeMethodCall',
'NullSafePropertyCall',
'SpreadAssignment',
'SpreadOneItem',
'SpreadRemoval',
'Ternary',
'Throw_',
'Catch_',
'PregMatchMatches',
'PregMatchRemoveCaret',
'PregMatchRemoveDollar',
'PregMatchRemoveFlags',
'PregQuote',
'ArrayItemRemoval',
'CatchBlockRemoval',
'CloneRemoval',
'ConcatOperandRemoval',
'FunctionCallRemoval',
'MatchArmRemoval',
'MethodCallRemoval',
'SharedCaseRemoval',
'ArrayOneItem',
'FloatNegation',
'FunctionCall',
'IntegerNegation',
'NewObject',
'This',
'YieldValue',
'Spaceship',
'DoWhile',
'Foreach_',
'For_',
'While_',
'CastArray',
'CastBool',
'CastFloat',
'CastInt',
'CastObject',
'CastString',
'UnwrapArrayChangeKeyCase',
'UnwrapArrayChunk',
'UnwrapArrayColumn',
'UnwrapArrayCombine',
'UnwrapArrayDiff',
'UnwrapArrayDiffAssoc',
'UnwrapArrayDiffKey',
'UnwrapArrayDiffUassoc',
'UnwrapArrayDiffUkey',
'UnwrapArrayFilter',
'UnwrapArrayFlip',
'UnwrapArrayIntersect',
'UnwrapArrayIntersectAssoc',
'UnwrapArrayIntersectKey',
'UnwrapArrayIntersectUassoc',
'UnwrapArrayIntersectUkey',
'UnwrapArrayKeys',
'UnwrapArrayMerge',
'UnwrapArrayMergeRecursive',
'UnwrapArrayPad',
'UnwrapArrayReduce',
'UnwrapArrayReplace',
'UnwrapArrayReplaceRecursive',
'UnwrapArrayReverse',
'UnwrapArraySlice',
'UnwrapArraySplice',
'UnwrapArrayUdiff',
'UnwrapArrayUdiffAssoc',
'UnwrapArrayUdiffUassoc',
'UnwrapArrayUintersect',
'UnwrapArrayUintersectAssoc',
'UnwrapArrayUintersectUassoc',
'UnwrapArrayUnique',
'UnwrapArrayValues',
'UnwrapLcFirst',
'UnwrapLtrim',
'UnwrapRtrim',
'UnwrapStrIreplace',
'UnwrapStrRepeat',
'UnwrapStrReplace',
'UnwrapStrRev',
'UnwrapStrShuffle',
'UnwrapStrToLower',
'UnwrapStrToUpper',
'UnwrapSubstr',
'UnwrapTrim',
'UnwrapUcFirst',
'UnwrapUcWords',
'UnwrapFinally',
'BCMath',
'MBString',
'SyntaxError',
];

#[DataProvider('valuesProvider')]
public function test_it_can_be_instantiated(
string $description,
Expand Down Expand Up @@ -81,12 +246,9 @@ public static function valuesProvider(): iterable
];
}

/**
* @dataProvider mutatorsProvider
*/
public function test_it_must_define_remedies(
Mutator $mutator,
): void {
#[DataProvider('mutatorsProvider')]
public function test_it_must_define_remedies(Mutator $mutator): void
{
$this->assertNotNull(
$mutator::getDefinition()->getRemedies(),
sprintf(
Expand All @@ -96,21 +258,27 @@ public function test_it_must_define_remedies(
);
}

public function mutatorsProvider(): iterable
public static function mutatorsProvider(): iterable
{
$mutatorFactory = SingletonContainer::getContainer()->getMutatorFactory();

$mutators = $mutatorFactory->create(array_fill_keys(
ProfileList::ALL_MUTATORS,
[],
), false);
$mutators = $mutatorFactory->create(
array_fill_keys(
ProfileList::ALL_MUTATORS,
[],
),
false,
);

$checkedMutators = array_diff_key(
$mutators,
array_flip(self::MUTATORS_WITHOUT_REMEDIES),
);

foreach ($mutators as $name => $mutator) {
$this->assertInstanceOf(Mutator::class, $mutator);
foreach ($checkedMutators as $name => $mutator) {
self::assertInstanceOf(Mutator::class, $mutator);

yield $name => [
$mutator,
];
yield $name => [$mutator];
}
}
}

0 comments on commit 4c1f59f

Please sign in to comment.