Passed
Push — main ( ed04a6...9907fd )
by Sebastian
04:22
created

CloverXmlTest::testFileNotFound()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 6
rs 10
1
<?php
2
3
/**
4
 * This file is part of CaptainHook
5
 *
6
 * (c) Sebastian Feldmann <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace CaptainHook\App\Hook\PHP\CoverageResolver;
13
14
use Exception;
15
use PHPUnit\Framework\TestCase;
16
17
class CloverXmlTest extends TestCase
18
{
19
    public function testValid(): void
20
    {
21
        $resolver = new CloverXML(CH_PATH_FILES . '/coverage/valid.xml');
22
        $coverage = $resolver->getCoverage();
23
24
        $this->assertEquals(95, $coverage);
25
    }
26
27
    public function testValid100Percent(): void
28
    {
29
        $resolver = new CloverXML(CH_PATH_FILES . '/coverage/valid-100.xml');
30
        $coverage = $resolver->getCoverage();
31
32
        $this->assertEquals(100, $coverage);
33
    }
34
35
    public function testFileNotFound(): void
36
    {
37
        $this->expectException(Exception::class);
38
39
        $resolver = new CloverXML('foo.xml');
40
        $this->assertNull($resolver);
41
    }
42
43
    public function testCrapMetrics(): void
44
    {
45
        $this->expectException(Exception::class);
46
47
        $resolver = new CloverXML(CH_PATH_FILES . '/coverage/invalid-crap.xml');
48
        $resolver->getCoverage();
49
    }
50
51
    public function testInvalidXML(): void
52
    {
53
        $this->expectException(Exception::class);
54
55
        $resolver = new CloverXML(CH_PATH_FILES . '/coverage/no-metrics.xml');
56
        $this->assertNull($resolver);
57
    }
58
59
    public function testInvalidMetrics(): void
60
    {
61
        $this->expectException(Exception::class);
62
63
        $resolver = new CloverXML(CH_PATH_FILES . '/coverage/invalid-metrics.xml');
64
        $resolver->getCoverage();
65
    }
66
}
67