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

LoadPhpMdReportStrictTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
B testClassCanLoad() 0 28 1
A testCorrectMissingFile() 0 6 1
1
<?php
2
namespace exussum12\CoverageChecker\tests;
3
4
use PHPUnit\Framework\TestCase;
5
use exussum12\CoverageChecker\PhpMdLoaderStrict;
6
7
class LoadPhpMdReportStrictTest extends TestCase
8
{
9
    public function testClassCanLoad()
10
    {
11
        $phpmd = new PhpMdLoaderStrict(__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
        $this->assertTrue($phpmd->isValidLine($file, 10));
36
    }
37
38
    public function testCorrectMissingFile()
39
    {
40
        $phpmd = new PhpMdLoaderStrict(__DIR__ . '/fixtures/phpmd.xml');
41
42
        $this->assertTrue($phpmd->handleNotFoundFile());
43
    }
44
}
45