Skip to content

Commit

Permalink
Add ignoreSourceCodeByRegex key for custom mutator definitions (#1385)
Browse files Browse the repository at this point in the history
Fixes #1384
  • Loading branch information
maks-rafalko committed Oct 29, 2020
1 parent 46c17a7 commit d1e4b90
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 0 deletions.
24 changes: 24 additions & 0 deletions resources/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,12 @@
"type": "string"
}
},
"ignoreSourceCodeByRegex": {
"type": "array",
"items": {
"type": "string"
}
},
"settings": {
"type": "object",
"additionalProperties": false,
Expand Down Expand Up @@ -258,6 +264,12 @@
"type": "string"
}
},
"ignoreSourceCodeByRegex": {
"type": "array",
"items": {
"type": "string"
}
},
"settings": {
"type": "object",
"additionalProperties": false,
Expand Down Expand Up @@ -358,6 +370,12 @@
"type": "string"
}
},
"ignoreSourceCodeByRegex": {
"type": "array",
"items": {
"type": "string"
}
},
"settings": {
"type": "object",
"additionalProperties": false,
Expand Down Expand Up @@ -410,6 +428,12 @@
"type": "string"
}
},
"ignoreSourceCodeByRegex": {
"type": "array",
"items": {
"type": "string"
}
},
"settings": {
"type": "object",
"additionalProperties": false,
Expand Down
104 changes: 104 additions & 0 deletions tests/phpunit/Configuration/Schema/SchemaConfigurationFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1005,6 +1005,32 @@ public function provideRawConfig(): iterable
]),
];

yield '[mutators][TrueValue] ignoreSourceCodeByRegex' => [
<<<'JSON'
{
"source": {
"directories": ["src"]
},
"mutators": {
"TrueValue": {
"ignoreSourceCodeByRegex": [".*test.*"]
}
}
}
JSON
,
self::createConfig([
'source' => new Source(['src'], []),
'mutators' => [
'TrueValue' => (object) [
'ignoreSourceCodeByRegex' => [
'.*test.*',
],
],
],
]),
];

yield '[mutators][TrueValue] empty & untrimmed ignore' => [
<<<'JSON'
{
Expand Down Expand Up @@ -1187,6 +1213,32 @@ public function provideRawConfig(): iterable
]),
];

yield '[mutators][ArrayItemRemoval] ignoreSourceCodeByRegex' => [
<<<'JSON'
{
"source": {
"directories": ["src"]
},
"mutators": {
"ArrayItemRemoval": {
"ignoreSourceCodeByRegex": [".*test.*"]
}
}
}
JSON
,
self::createConfig([
'source' => new Source(['src'], []),
'mutators' => [
'ArrayItemRemoval' => (object) [
'ignoreSourceCodeByRegex' => [
'.*test.*',
],
],
],
]),
];

yield '[mutators][ArrayItemRemoval] empty & untrimmed ignore' => [
<<<'JSON'
{
Expand Down Expand Up @@ -1369,6 +1421,32 @@ public function provideRawConfig(): iterable
]),
];

yield '[mutators][BCMath] ignoreSourceCodeByRegex' => [
<<<'JSON'
{
"source": {
"directories": ["src"]
},
"mutators": {
"BCMath": {
"ignoreSourceCodeByRegex": [".*test.*"]
}
}
}
JSON
,
self::createConfig([
'source' => new Source(['src'], []),
'mutators' => [
'BCMath' => (object) [
'ignoreSourceCodeByRegex' => [
'.*test.*',
],
],
],
]),
];

yield '[mutators][BCMath] empty & untrimmed ignore' => [
<<<'JSON'
{
Expand Down Expand Up @@ -1553,6 +1631,32 @@ public function provideRawConfig(): iterable
]),
];

yield '[mutators][MBString] ignoreSourceCodeByRegex' => [
<<<'JSON'
{
"source": {
"directories": ["src"]
},
"mutators": {
"MBString": {
"ignoreSourceCodeByRegex": [".*test.*"]
}
}
}
JSON
,
self::createConfig([
'source' => new Source(['src'], []),
'mutators' => [
'MBString' => (object) [
'ignoreSourceCodeByRegex' => [
'.*test.*',
],
],
],
]),
];

yield '[mutators][MBString] empty & untrimmed ignore' => [
<<<'JSON'
{
Expand Down

0 comments on commit d1e4b90

Please sign in to comment.