LoadPhpMdReportTest::testClassCanLoad()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 27
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 16
nc 1
nop 0
dl 0
loc 27
rs 9.7333
c 0
b 0
f 0
1
<?php
2
namespace exussum12\CoverageChecker\tests\Loaders;
3
4
use PHPUnit\Framework\TestCase;
5
use exussum12\CoverageChecker\Loaders\PhpMd;
6
7
class LoadPhpMdReportTest extends TestCase
8
{
9
    public function testClassCanLoad()
10
    {
11
        $phpmd = new PhpMd(__DIR__ . '/../fixtures/phpmd.xml');
12
        $lines = $phpmd->parseLines();
13
        $file = '/full/path/to/file/src/CoverageCheck.php';
14
        $expected = [$file];
15
        $expectedError = [
16
            'The method addUnCoveredLine has a boolean flag argument ' .
17
            '$message, which is a certain sign of a ' .
18
            'Single Responsibility Principle violation.'
19
        ];
20
21
        $this->assertEquals($expected, $lines);
22
23
        $this->assertEquals(
24
            $expectedError,
25
            $phpmd->getErrorsOnLine($file, 57)
26
        );
27
        //second should respond as no errors as the first range reported it
28
        $this->assertEquals(
29
            [],
30
            $phpmd->getErrorsOnLine($file, 58)
31
        );
32
33
        $this->assertEquals(
34
            [],
35
            $phpmd->getErrorsOnLine($file, 10)
36
        );
37
    }
38
39
    public function testCorrectMissingFile()
40
    {
41
        $phpmd = new PhpMd(__DIR__ . '/fixtures/phpmd.xml');
42
43
        $this->assertTrue($phpmd->handleNotFoundFile());
44
    }
45
}
46