JsonOutputFormatterTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 33
c 1
b 0
f 0
dl 0
loc 50
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testNoIssues() 0 7 1
A testName() 0 3 1
A testWithIssues() 0 29 1
A getOutputFormatter() 0 3 1
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\JsonOutputFormatter;
9
10
final class JsonOutputFormatterTest extends AbstractOutputFormatterTest
11
{
12
    public function testName(): void
13
    {
14
        $this->assertName('json');
15
    }
16
17
    public function testNoIssues(): void
18
    {
19
        $expectedOutput = <<<EOF
20
[]
21
EOF;
22
23
        $this->assertNoIssuesOutput($expectedOutput);
24
    }
25
26
    public function testWithIssues(): void
27
    {
28
        $expectedOutput = <<<EOF
29
[
30
    {
31
        "file": "\/FILE_1",
32
        "line": 10,
33
        "type": "TYPE_1",
34
        "message": "MESSAGE_1",
35
        "severity": "error"
36
    },
37
    {
38
        "file": "\/FILE_1",
39
        "line": 12,
40
        "type": "TYPE_2",
41
        "message": "MESSAGE_2",
42
        "severity": "error"
43
    },
44
    {
45
        "file": "\/FILE_2",
46
        "line": 0,
47
        "type": "TYPE_1",
48
        "message": "MESSAGE_3",
49
        "severity": "warning"
50
    }
51
]
52
EOF;
53
54
        $this->assertIssuesOutput($expectedOutput);
55
    }
56
57
    protected function getOutputFormatter(): OutputFormatter
58
    {
59
        return new JsonOutputFormatter();
60
    }
61
}
62