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

LoadXMLReportTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 35
rs 10
c 1
b 0
f 0
wmc 2
lcom 1
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
B testLoadXML() 0 25 1
A testCorrectMissingFile() 0 6 1
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