From e7d280f3c47de47da3803441977a6e985cf441d8 Mon Sep 17 00:00:00 2001 From: maks-rafalko Date: Sat, 31 Oct 2020 18:02:45 +0300 Subject: [PATCH] Implement UnwrapStrShuffle mutator --- resources/schema.json | 1 + src/Mutator/ProfileList.php | 2 + src/Mutator/Unwrap/UnwrapStrShuffle.php | 72 +++++++ .../Mutator/Unwrap/UnwrapStrShuffleTest.php | 191 ++++++++++++++++++ 4 files changed, 266 insertions(+) create mode 100644 src/Mutator/Unwrap/UnwrapStrShuffle.php create mode 100644 tests/phpunit/Mutator/Unwrap/UnwrapStrShuffleTest.php diff --git a/resources/schema.json b/resources/schema.json index 117bdae6a..c99a60cb0 100644 --- a/resources/schema.json +++ b/resources/schema.json @@ -351,6 +351,7 @@ "UnwrapLcFirst": { "$ref": "#/definitions/default-mutator-config" }, "UnwrapStrRepeat": { "$ref": "#/definitions/default-mutator-config" }, "UnwrapStrReplace": { "$ref": "#/definitions/default-mutator-config" }, + "UnwrapStrShuffle": { "$ref": "#/definitions/default-mutator-config" }, "UnwrapStrToLower": { "$ref": "#/definitions/default-mutator-config" }, "UnwrapStrToUpper": { "$ref": "#/definitions/default-mutator-config" }, "UnwrapTrim": { "$ref": "#/definitions/default-mutator-config" }, diff --git a/src/Mutator/ProfileList.php b/src/Mutator/ProfileList.php index 2cc11e3a6..cbf98fc52 100644 --- a/src/Mutator/ProfileList.php +++ b/src/Mutator/ProfileList.php @@ -241,6 +241,7 @@ final class ProfileList Mutator\Unwrap\UnwrapLcFirst::class, Mutator\Unwrap\UnwrapStrRepeat::class, Mutator\Unwrap\UnwrapStrReplace::class, + Mutator\Unwrap\UnwrapStrShuffle::class, Mutator\Unwrap\UnwrapStrToLower::class, Mutator\Unwrap\UnwrapStrToUpper::class, Mutator\Unwrap\UnwrapTrim::class, @@ -423,6 +424,7 @@ final class ProfileList 'UnwrapLcFirst' => Mutator\Unwrap\UnwrapLcFirst::class, 'UnwrapStrRepeat' => Mutator\Unwrap\UnwrapStrRepeat::class, 'UnwrapStrReplace' => Mutator\Unwrap\UnwrapStrReplace::class, + 'UnwrapStrShuffle' => Mutator\Unwrap\UnwrapStrShuffle::class, 'UnwrapStrToLower' => Mutator\Unwrap\UnwrapStrToLower::class, 'UnwrapStrToUpper' => Mutator\Unwrap\UnwrapStrToUpper::class, 'UnwrapTrim' => Mutator\Unwrap\UnwrapTrim::class, diff --git a/src/Mutator/Unwrap/UnwrapStrShuffle.php b/src/Mutator/Unwrap/UnwrapStrShuffle.php new file mode 100644 index 000000000..380131e9d --- /dev/null +++ b/src/Mutator/Unwrap/UnwrapStrShuffle.php @@ -0,0 +1,72 @@ +doTest($input, $expected); + } + + public function mutationsProvider(): iterable + { + yield 'It mutates correctly when provided with a string' => [ + <<<'PHP' + [ + <<<'PHP' + [ + <<<'PHP' + [ + <<<'PHP' + [ + <<<'PHP' + [ + <<<'PHP' +bar()); +PHP + , + <<<'PHP' +bar(); +PHP + ]; + + yield 'It mutates correctly when provided with a more complex situation' => [ + <<<'PHP' + [ + <<<'PHP' + [ + <<<'PHP' + [ + <<<'PHP' +