Skip to content

Commit

Permalink
Update tests to remove "because reasons" and add the full stop
Browse files Browse the repository at this point in the history
  • Loading branch information
spaze committed Nov 26, 2023
1 parent b8b2faf commit b8b11f4
Show file tree
Hide file tree
Showing 33 changed files with 282 additions and 251 deletions.
4 changes: 2 additions & 2 deletions tests/Calls/EchoCallsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected function getRule(): Rule
$filePath = new FilePath(new FileHelper(__DIR__));
$allowed = new Allowed($formatter, $normalizer, new AllowedPath($filePath));
return new EchoCalls(
new DisallowedCallsRuleErrors($allowed, new Identifier(), $filePath),
new DisallowedCallsRuleErrors($allowed, new Identifier(), $filePath, $formatter),
new DisallowedCallFactory($formatter, $normalizer, $allowed),
[
[
Expand All @@ -49,7 +49,7 @@ public function testRule(): void
// Based on the configuration above, in this file:
$this->analyse([__DIR__ . '/../src/disallowed/functionCalls.php'], [
[
'Calling echo() is forbidden, because reasons',
'Calling echo() is forbidden.',
42,
],
]);
Expand Down
4 changes: 2 additions & 2 deletions tests/Calls/EmptyCallsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected function getRule(): Rule
$filePath = new FilePath(new FileHelper(__DIR__));
$allowed = new Allowed($formatter, $normalizer, new AllowedPath($filePath));
return new EmptyCalls(
new DisallowedCallsRuleErrors($allowed, new Identifier(), $filePath),
new DisallowedCallsRuleErrors($allowed, new Identifier(), $filePath, $formatter),
new DisallowedCallFactory($formatter, $normalizer, $allowed),
[
[
Expand All @@ -49,7 +49,7 @@ public function testRule(): void
// Based on the configuration above, in this file:
$this->analyse([__DIR__ . '/../src/disallowed/functionCalls.php'], [
[
'Calling empty() is forbidden, because reasons',
'Calling empty() is forbidden.',
41,
],
]);
Expand Down
4 changes: 2 additions & 2 deletions tests/Calls/EvalCallsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected function getRule(): Rule
$filePath = new FilePath(new FileHelper(__DIR__));
$allowed = new Allowed($formatter, $normalizer, new AllowedPath($filePath));
return new EvalCalls(
new DisallowedCallsRuleErrors($allowed, new Identifier(), $filePath),
new DisallowedCallsRuleErrors($allowed, new Identifier(), $filePath, $formatter),
new DisallowedCallFactory($formatter, $normalizer, $allowed),
[
[
Expand All @@ -49,7 +49,7 @@ public function testRule(): void
// Based on the configuration above, in this file:
$this->analyse([__DIR__ . '/../src/disallowed/functionCalls.php'], [
[
'Calling eval() is forbidden, because reasons',
'Calling eval() is forbidden.',
28,
],
]);
Expand Down
10 changes: 5 additions & 5 deletions tests/Calls/ExitDieCallsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected function getRule(): Rule
$filePath = new FilePath(new FileHelper(__DIR__));
$allowed = new Allowed($formatter, $normalizer, new AllowedPath($filePath));
return new ExitDieCalls(
new DisallowedCallsRuleErrors($allowed, new Identifier(), $filePath),
new DisallowedCallsRuleErrors($allowed, new Identifier(), $filePath, $formatter),
new DisallowedCallFactory($formatter, $normalizer, $allowed),
[
[
Expand All @@ -52,19 +52,19 @@ public function testRule(): void
// Based on the configuration above, in this file:
$this->analyse([__DIR__ . '/../src/disallowed/functionCalls.php'], [
[
'Calling die() is forbidden, because reasons',
'Calling die() is forbidden.',
30,
],
[
'Calling die() is forbidden, because reasons',
'Calling die() is forbidden.',
33,
],
[
'Calling exit() is forbidden, because reasons',
'Calling exit() is forbidden.',
36,
],
[
'Calling exit() is forbidden, because reasons',
'Calling exit() is forbidden.',
39,
],
]);
Expand Down
4 changes: 2 additions & 2 deletions tests/Calls/FunctionCallsAllowInFunctionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected function getRule(): Rule
$filePath = new FilePath(new FileHelper(__DIR__));
$allowed = new Allowed($formatter, $normalizer, new AllowedPath($filePath));
return new FunctionCalls(
new DisallowedCallsRuleErrors($allowed, new Identifier(), $filePath),
new DisallowedCallsRuleErrors($allowed, new Identifier(), $filePath, $formatter),
new DisallowedCallFactory($formatter, $normalizer, $allowed),
$this->createReflectionProvider(),
[
Expand All @@ -56,7 +56,7 @@ public function testRule(): void
$this->analyse([__DIR__ . '/../libs/Functions.php'], [
[
// expect this error message:
'Calling sha1() is forbidden, because reasons [sha1() matches sha*()]',
'Calling sha1() is forbidden. [sha1() matches sha*()]',
// on this line:
15,
],
Expand Down
4 changes: 2 additions & 2 deletions tests/Calls/FunctionCallsAllowInMethodsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected function getRule(): Rule
$filePath = new FilePath(new FileHelper(__DIR__));
$allowed = new Allowed($formatter, $normalizer, new AllowedPath($filePath));
return new FunctionCalls(
new DisallowedCallsRuleErrors($allowed, new Identifier(), $filePath),
new DisallowedCallsRuleErrors($allowed, new Identifier(), $filePath, $formatter),
new DisallowedCallFactory($formatter, $normalizer, $allowed),
$this->createReflectionProvider(),
[
Expand Down Expand Up @@ -65,7 +65,7 @@ public function testRule(): void
$this->analyse([__DIR__ . '/../libs/Royale.php'], [
[
// expect this error message:
'Calling sha1() is forbidden, because reasons',
'Calling sha1() is forbidden.',
// on this line:
11,
],
Expand Down
8 changes: 4 additions & 4 deletions tests/Calls/FunctionCallsDefinedInTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected function getRule(): Rule
$filePath = new FilePath(new FileHelper(__DIR__), __DIR__);
$allowed = new Allowed($formatter, $normalizer, new AllowedPath($filePath));
return new FunctionCalls(
new DisallowedCallsRuleErrors($allowed, new Identifier(), $filePath),
new DisallowedCallsRuleErrors($allowed, new Identifier(), $filePath, $formatter),
new DisallowedCallFactory($formatter, $normalizer, $allowed),
$this->createReflectionProvider(),
[
Expand Down Expand Up @@ -67,16 +67,16 @@ public function testRule(): void
$this->analyse([__DIR__ . '/../src/disallowed/functionCallsDefinedIn.php'], [
[
// expect this error message:
'Calling Foo\Bar\Waldo\fred() is forbidden, because reasons [Foo\Bar\Waldo\fred() matches Foo\Bar\Waldo\f*()]',
'Calling Foo\Bar\Waldo\fred() is forbidden. [Foo\Bar\Waldo\fred() matches Foo\Bar\Waldo\f*()]',
// on this line:
5,
],
[
'Calling Foo\Bar\Waldo\foo() is forbidden, because reasons [Foo\Bar\Waldo\foo() matches Foo\Bar\Waldo\f*()]',
'Calling Foo\Bar\Waldo\foo() is forbidden. [Foo\Bar\Waldo\foo() matches Foo\Bar\Waldo\f*()]',
6,
],
[
'Calling Foo\Bar\Waldo\quux() is forbidden, because reasons [Foo\Bar\Waldo\quux() matches Foo\Bar\Waldo\q*x()]',
'Calling Foo\Bar\Waldo\quux() is forbidden. [Foo\Bar\Waldo\quux() matches Foo\Bar\Waldo\q*x()]',
13,
],
]);
Expand Down
16 changes: 8 additions & 8 deletions tests/Calls/FunctionCallsInMultipleNamespacesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected function getRule(): Rule
$filePath = new FilePath(new FileHelper(__DIR__));
$allowed = new Allowed($formatter, $normalizer, new AllowedPath($filePath));
return new FunctionCalls(
new DisallowedCallsRuleErrors($allowed, new Identifier(), $filePath),
new DisallowedCallsRuleErrors($allowed, new Identifier(), $filePath, $formatter),
new DisallowedCallFactory($formatter, $normalizer, $allowed),
$this->createReflectionProvider(),
[
Expand All @@ -55,32 +55,32 @@ public function testRule(): void
$this->analyse([__DIR__ . '/../src/FunctionInMultipleNamespaces.php'], [
[
// expect this error message:
'Calling __() (as alias()) is forbidden, use MyNamespace\__ instead',
'Calling __() (as alias()) is forbidden, use MyNamespace\__ instead.',
// on this line:
20,
],
[
'Calling MyNamespace\__() (as __()) is forbidden, ha ha ha nope',
'Calling MyNamespace\__() (as __()) is forbidden, ha ha ha nope.',
26,
],
[
'Calling printf() is forbidden, because reasons',
'Calling printf() is forbidden.',
30,
],
[
'Calling printf() is forbidden, because reasons',
'Calling printf() is forbidden.',
31,
],
[
'Calling MyNamespace\__() (as alias()) is forbidden, ha ha ha nope',
'Calling MyNamespace\__() (as alias()) is forbidden, ha ha ha nope.',
39,
],
[
'Calling printf() is forbidden, because reasons',
'Calling printf() is forbidden.',
40,
],
[
'Calling printf() is forbidden, because reasons',
'Calling printf() is forbidden.',
41,
],
]);
Expand Down
48 changes: 24 additions & 24 deletions tests/Calls/FunctionCallsNamedParamsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ protected function getRule(): Rule
$filePath = new FilePath(new FileHelper(__DIR__));
$allowed = new Allowed($formatter, $normalizer, new AllowedPath($filePath));
return new FunctionCalls(
new DisallowedCallsRuleErrors($allowed, new Identifier(), $filePath),
new DisallowedCallsRuleErrors($allowed, new Identifier(), $filePath, $formatter),
new DisallowedCallFactory($formatter, $normalizer, $allowed),
$this->createReflectionProvider(),
[
Expand Down Expand Up @@ -99,110 +99,110 @@ public function testRule(): void
$this->analyse([__DIR__ . '/../src/disallowed/functionCallsNamedParams.php'], [
[
// expect this error message:
'Calling Foo\Bar\Waldo\foo() (as foo()) is forbidden, because reasons',
'Calling Foo\Bar\Waldo\foo() (as foo()) is forbidden.',
// on this line:
12,
],
[
// no required param
'Calling Foo\Bar\Waldo\bar() (as bar()) is forbidden, because reasons',
'Calling Foo\Bar\Waldo\bar() (as bar()) is forbidden.',
19,
],
[
// missing $name + second param + $path
'Calling Foo\Bar\Waldo\bar() (as bar()) is forbidden, because reasons',
'Calling Foo\Bar\Waldo\bar() (as bar()) is forbidden.',
20,
],
[
// missing $name + second param + $path
'Calling Foo\Bar\Waldo\bar() (as bar()) is forbidden, because reasons',
'Calling Foo\Bar\Waldo\bar() (as bar()) is forbidden.',
21,
],
[
// missing $name + $path
'Calling Foo\Bar\Waldo\bar() (as bar()) is forbidden, because reasons',
'Calling Foo\Bar\Waldo\bar() (as bar()) is forbidden.',
22,
],
[
// missing $name + $path
'Calling Foo\Bar\Waldo\bar() (as bar()) is forbidden, because reasons',
'Calling Foo\Bar\Waldo\bar() (as bar()) is forbidden.',
23,
],
[
// missing $name
'Calling Foo\Bar\Waldo\bar() (as bar()) is forbidden, because reasons',
'Calling Foo\Bar\Waldo\bar() (as bar()) is forbidden.',
24,
],
[
'Calling Foo\Bar\Waldo\baz() (as baz()) is forbidden, because reasons',
'Calling Foo\Bar\Waldo\baz() (as baz()) is forbidden.',
29,
],
[
'Calling Foo\Bar\Waldo\baz() (as baz()) is forbidden, because reasons',
'Calling Foo\Bar\Waldo\baz() (as baz()) is forbidden.',
30,
],
[
'Calling Foo\Bar\Waldo\baz() (as baz()) is forbidden, because reasons',
'Calling Foo\Bar\Waldo\baz() (as baz()) is forbidden.',
31,
],
[
'Calling Foo\Bar\Waldo\baz() (as baz()) is forbidden, because reasons',
'Calling Foo\Bar\Waldo\baz() (as baz()) is forbidden.',
32,
],
[
'Calling Foo\Bar\Waldo\waldo() (as waldo()) is forbidden, because reasons',
'Calling Foo\Bar\Waldo\waldo() (as waldo()) is forbidden.',
35,
],
[
'Calling Foo\Bar\Waldo\waldo() (as waldo()) is forbidden, because reasons',
'Calling Foo\Bar\Waldo\waldo() (as waldo()) is forbidden.',
36,
],
[
'Calling Foo\Bar\Waldo\waldo() (as waldo()) is forbidden, because reasons',
'Calling Foo\Bar\Waldo\waldo() (as waldo()) is forbidden.',
37,
],
[
'Calling Foo\Bar\Waldo\waldo() (as waldo()) is forbidden, because reasons',
'Calling Foo\Bar\Waldo\waldo() (as waldo()) is forbidden.',
38,
],
]);
// Based on the configuration above, no errors in this file:
$this->analyse([__DIR__ . '/../src/disallowed-allow/functionCallsNamedParams.php'], [
[
'Calling Foo\Bar\Waldo\foo() (as foo()) is forbidden, because reasons',
'Calling Foo\Bar\Waldo\foo() (as foo()) is forbidden.',
12,
],
[
'Calling Foo\Bar\Waldo\foo() (as foo()) is forbidden, because reasons',
'Calling Foo\Bar\Waldo\foo() (as foo()) is forbidden.',
13,
],
[
'Calling Foo\Bar\Waldo\foo() (as foo()) is forbidden, because reasons',
'Calling Foo\Bar\Waldo\foo() (as foo()) is forbidden.',
14,
],
[
// second param not 'VALUE'
'Calling Foo\Bar\Waldo\baz() (as baz()) is forbidden, because reasons',
'Calling Foo\Bar\Waldo\baz() (as baz()) is forbidden.',
29,
],
[
// second param not 'VALUE'
'Calling Foo\Bar\Waldo\baz() (as baz()) is forbidden, because reasons',
'Calling Foo\Bar\Waldo\baz() (as baz()) is forbidden.',
31,
],
[
// not $value param
'Calling Foo\Bar\Waldo\waldo() (as waldo()) is forbidden, because reasons',
'Calling Foo\Bar\Waldo\waldo() (as waldo()) is forbidden.',
35,
],
[
// not $value param
'Calling Foo\Bar\Waldo\waldo() (as waldo()) is forbidden, because reasons',
'Calling Foo\Bar\Waldo\waldo() (as waldo()) is forbidden.',
36,
],
[
// $value is not 'VALUE'
'Calling Foo\Bar\Waldo\waldo() (as waldo()) is forbidden, because reasons',
'Calling Foo\Bar\Waldo\waldo() (as waldo()) is forbidden.',
37,
],
]);
Expand Down
Loading

0 comments on commit b8b11f4

Please sign in to comment.