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

LoadPhpMdReportTest::testClassCanLoad()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 30
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

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