TableOutputFormatterTest::testName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace DaveLiddament\StaticAnalysisResultsBaseliner\Tests\Unit\Plugins\OutputFormatters;
6
7
use DaveLiddament\StaticAnalysisResultsBaseliner\Domain\OutputFormatter\OutputFormatter;
8
use DaveLiddament\StaticAnalysisResultsBaseliner\Plugins\OutputFormatters\TableOutputFormatter;
9
10
final class TableOutputFormatterTest extends AbstractOutputFormatterTest
11
{
12
    public function testName(): void
13
    {
14
        $this->assertName('table');
15
    }
16
17
    public function testNoIssues(): void
18
    {
19
        $expectedOutput = <<<EOF
20
No issues
21
EOF;
22
23
        $this->assertNoIssuesOutput($expectedOutput);
24
    }
25
26
    public function testWithIssues(): void
27
    {
28
        $expectedOutput = <<<EOF
29
30
FILE: /FILE_1
31
+------+-------------+
32
| Line | Description |
33
+------+-------------+
34
| 10   | MESSAGE_1   |
35
| 12   | MESSAGE_2   |
36
+------+-------------+
37
38
FILE: /FILE_2
39
+------+--------------------+
40
| Line | Description        |
41
+------+--------------------+
42
| 0    | WARNING: MESSAGE_3 |
43
+------+--------------------+
44
45
These results include warnings. To exclude warnings from output use the --ignore-warnings flag.
46
47
EOF;
48
49
        $this->assertIssuesOutput($expectedOutput);
50
    }
51
52
    public function testWithIssuesAndWarningsIgnored(): void
53
    {
54
        $expectedOutput = <<<EOF
55
56
FILE: /FILE_1
57
+------+-------------+
58
| Line | Description |
59
+------+-------------+
60
| 10   | MESSAGE_1   |
61
| 12   | MESSAGE_2   |
62
+------+-------------+
63
64
EOF;
65
66
        $this->assertIssuesOutputWithWarningsIgnored($expectedOutput);
67
    }
68
69
    protected function getOutputFormatter(): OutputFormatter
70
    {
71
        return new TableOutputFormatter();
72
    }
73
}
74