Passed
Branch master (cd2b9b)
by Scott
03:31
created

LoadXMLReportTest::testLoadXML()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 25
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 19
nc 1
nop 0
dl 0
loc 25
rs 8.8571
c 1
b 0
f 0
1
<?php
2
namespace exussum12\CoverageChecker\tests;
3
4
use PHPUnit\Framework\TestCase;
5
6
use exussum12\CoverageChecker\XMLReport;
7
8
class LoadXMLReportTest extends TestCase
9
{
10
    public function testLoadXML()
11
    {
12
        $xmlReport = new XMLReport(__DIR__ . '/fixtures/coverage.xml');
13
        $coveredLines = $xmlReport->getLines();
14
        $expected = [
15
            '/path/to/file/changedFile.php' => [
16
                10 => 4,
17
                11 => 4,
18
                14 => 0,
19
                15 => 3,
20
                18 => 3,
21
                19 => 3,
22
                22 => 3,
23
            ],
24
            '/path/to/file/otherFile.php' => [
25
                9 => 4,
26
                10 => 4,
27
            ],
28
        ];
29
        $this->assertEquals($expected, $coveredLines);
30
        $this->assertFalse($xmlReport->isValidLine('/path/to/file/changedFile.php', 14));
31
        $this->assertTrue($xmlReport->isValidLine('/path/to/file/changedFile.php', 10));
32
        //True as the report doesnt contain the file
33
        $this->assertTrue($xmlReport->isValidLine('/path/to/file/NonExistantFile.php', 6));
34
    }
35
36
    public function testCorrectMissingFile()
37
    {
38
        $xmlReport = new XMLReport(__DIR__ . '/fixtures/coverage.xml');
39
40
        $this->assertNull($xmlReport->handleNotFoundFile());
41
    }
42
}
43