|
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
|
|
|
|