Skip to content

Commit b3c62fb

Browse files
bloepstaabm
authored andcommitted
add unit tests
1 parent 16eb94e commit b3c62fb

File tree

4 files changed

+32
-2
lines changed

4 files changed

+32
-2
lines changed

tests/AnalyzeApplicationTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ function testTextPrinting():void
2323
Deprecations: 2
2424
Invalid-Phpdocs: 5
2525
Unknown-Types: 1
26+
Anonymous-Variables: 4
2627
2728
PHP;
2829

@@ -41,7 +42,7 @@ function testJsonPrinting():void
4142
$rendered = str_replace(trim(json_encode(__DIR__), '"'), '', $rendered);
4243

4344
$expected = <<<PHP
44-
[{"\/fixtures\/all-in.neon":{"Classes-Cognitive-Complexity":70,"Deprecations":2,"Invalid-Phpdocs":5,"Unknown-Types":1}}]
45+
[{"\/fixtures\/all-in.neon":{"Classes-Cognitive-Complexity":70,"Deprecations":2,"Invalid-Phpdocs":5,"Unknown-Types":1,"Anonymous-Variables":4}}]
4546
PHP;
4647

4748
$this->assertSame($expected, $rendered);

tests/BaselineAnalyzerTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,12 @@ function testUnknownTypes():void
5656
$this->assertSame(7, $result->unknownTypes);
5757
}
5858

59+
function testAnonymousVariables():void
60+
{
61+
$analyzer = new BaselineAnalyzer(Baseline::forFile(__DIR__ . '/fixtures/anonymous-variables.neon'));
62+
$result = $analyzer->analyze();
63+
64+
$this->assertSame(4, $result->anonymousVariables);
65+
}
66+
5967
}

tests/fixtures/all-in.neon

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,14 @@ parameters:
7878
-
7979
message: "#^Property ActionMailer\\:\\:\\$template_root has unknown class unknown_type as its type\\.$#"
8080
count: 1
81-
path: lib/ActionMailer.php
81+
path: lib/ActionMailer.php
82+
83+
-
84+
message: "#^Anonymous variable in a `\\$lang\\-\\>\\.\\.\\.\\(\\)` method call can lead to false dead methods\\. Make sure the variable type is known$#"
85+
count: 1
86+
path: application/Rocket/lib/Prospect/Service/ProspectDetailService.php
87+
88+
-
89+
message: "#^Anonymous variables in a \"\\$element\\-\\>value\\[0\\]\\-\\>\\.\\.\\.\" property fetch can lead to false dead property\\. Make sure the variable type is known$#"
90+
count: 3
91+
path: application/Rocket/lib/bulkConsumerCheckout/integration/VatValidationClient.php
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
parameters:
2+
ignoreErrors:
3+
-
4+
message: "#^Anonymous variable in a `\\$lang\\-\\>\\.\\.\\.\\(\\)` method call can lead to false dead methods\\. Make sure the variable type is known$#"
5+
count: 1
6+
path: application/Rocket/lib/Prospect/Service/ProspectDetailService.php
7+
8+
-
9+
message: "#^Anonymous variables in a \"\\$element\\-\\>value\\[0\\]\\-\\>\\.\\.\\.\" property fetch can lead to false dead property\\. Make sure the variable type is known$#"
10+
count: 3
11+
path: application/Rocket/lib/bulkConsumerCheckout/integration/VatValidationClient.php

0 commit comments

Comments
 (0)