forked from vimeo/psalm
/
ByIssueLevelAndTypeReportTest.php
97 lines (72 loc) · 3.27 KB
/
ByIssueLevelAndTypeReportTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
namespace Psalm\Tests;
use PHPUnit\Framework\TestCase;
use Psalm\Internal\Analyzer\IssueData;
use Psalm\Report\ByIssueLevelAndTypeReport;
use Psalm\Report\ReportOptions;
class ByIssueLevelAndTypeReportTest extends TestCase
{
public function testItGeneratesReport(): void
{
$issuesData = [
$this->issueData(2, 'SomeLevel2IssueType'),
$this->issueData(-1, 'SomeAlwaysReportedIssueType'),
$this->issueData(4, 'SomeLevel4IssueType'),
$this->issueData(7, 'SomeLevel7IssueType'),
$this->issueData(4, 'AnotherLevel4IssueType'),
$this->issueData(4, 'SomeLevel4IssueType'), // same issue type as above, will be sorted together
$this->issueData(1, 'SomeIssueType'),
$this->issueData(-2, 'SomeFeatureSpecificIssueType'),
];
$reportOptions = new ReportOptions();
$reportOptions->use_color = false;
$report = new ByIssueLevelAndTypeReport($issuesData, [], $reportOptions);
$this->assertSame(<<<EXPECTED
|----------------------------------------------------------------------------------------|
| Issues have been sorted by level and type. Feature-specific issues and the |
| most serious issues that will always be reported are listed first, with |
| remaining issues in level order. Issues near the top are usually the most serious. |
| Reducing the errorLevel in psalm.xml will suppress output of issues further down |
| this report. |
| |
| The level at which issue is reported as an error is given in brackets - e.g. |
| `ERROR (2): MissingReturnType` indicates that MissingReturnType is only reported |
| as an error when Psalm's level is set to 4 or below. |
| |
| Issues are shown or hidden in this report according to current settings. For |
| the most complete report set Psalm's error level to 0 or use --show-info=true |
| See https://psalm.dev/docs/running_psalm/error_levels/ |
|----------------------------------------------------------------------------------------|
ERROR: SomeAlwaysReportedIssueType - file.php:1:1 - message
ERROR: SomeFeatureSpecificIssueType - file.php:1:1 - message
ERROR (7): SomeLevel7IssueType - file.php:1:1 - message
ERROR (4): AnotherLevel4IssueType - file.php:1:1 - message
ERROR (4): SomeLevel4IssueType - file.php:1:1 - message
ERROR (4): SomeLevel4IssueType - file.php:1:1 - message
ERROR (2): SomeLevel2IssueType - file.php:1:1 - message
ERROR (1): SomeIssueType - file.php:1:1 - message
EXPECTED, $report->create());
}
public function issueData(int $errorLevel, string $type): IssueData
{
return new IssueData(
'error',
1,
1,
$type,
'message',
'file.php',
'/',
'',
'',
1,
1,
1,
1,
1,
1,
0,
$errorLevel
);
}
}