|
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\JunitOutputFormatter; |
|
9
|
|
|
|
|
10
|
|
|
final class JunitOutputFormatterTest extends AbstractOutputFormatterTest |
|
11
|
|
|
{ |
|
12
|
|
|
public function testName(): void |
|
13
|
|
|
{ |
|
14
|
|
|
$this->assertName('junit'); |
|
15
|
|
|
} |
|
16
|
|
|
|
|
17
|
|
|
public function testNoIssues(): void |
|
18
|
|
|
{ |
|
19
|
|
|
$expectedOutput = <<<XML |
|
20
|
|
|
<?xml version="1.0" encoding="UTF-8"?> |
|
21
|
|
|
<testsuites |
|
22
|
|
|
name="SARB" tests="1" failures="0"> |
|
23
|
|
|
<testsuite errors="0" tests="1" failures="0" name="Success"> |
|
24
|
|
|
<testcase name="Success"/> |
|
25
|
|
|
</testsuite> |
|
26
|
|
|
</testsuites> |
|
27
|
|
|
|
|
28
|
|
|
XML; |
|
29
|
|
|
|
|
30
|
|
|
$this->assertNoIssuesOutput($expectedOutput); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
public function testWithIssues(): void |
|
34
|
|
|
{ |
|
35
|
|
|
$expectedOutput = <<<XML |
|
36
|
|
|
<?xml version="1.0" encoding="UTF-8"?> |
|
37
|
|
|
<testsuites name="SARB" tests="3" failures="3"> |
|
38
|
|
|
<testsuite name="FILE_1" errors="0" tests="2" failures="2"> |
|
39
|
|
|
<testcase name="TYPE_1 at /FILE_1 (10:10)"> |
|
40
|
|
|
<failure type="error" message="MESSAGE_1"/> |
|
41
|
|
|
</testcase> |
|
42
|
|
|
<testcase name="TYPE_2 at /FILE_1 (12:0)"> |
|
43
|
|
|
<failure type="error" message="MESSAGE_2"/> |
|
44
|
|
|
</testcase> |
|
45
|
|
|
</testsuite> |
|
46
|
|
|
<testsuite name="FILE_2" errors="0" tests="1" failures="1"> |
|
47
|
|
|
<testcase name="TYPE_1 at /FILE_2 (0:0)"> |
|
48
|
|
|
<failure type="warning" message="MESSAGE_3"/> |
|
49
|
|
|
</testcase> |
|
50
|
|
|
</testsuite> |
|
51
|
|
|
</testsuites> |
|
52
|
|
|
|
|
53
|
|
|
XML; |
|
54
|
|
|
$this->assertIssuesOutput($expectedOutput); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
protected function getOutputFormatter(): OutputFormatter |
|
58
|
|
|
{ |
|
59
|
|
|
return new JunitOutputFormatter(); |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
|