PhpMndTest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 16
dl 0
loc 43
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A fileInputs() 0 6 1
A setUp() 0 6 1
A testLinesReturnCorrect() 0 5 1
A testGetOutput() 0 8 1
A testInvalidFile() 0 3 1
1
<?php
2
namespace exussum12\CoverageChecker\tests;
3
4
use PHPUnit\Framework\TestCase;
5
use exussum12\CoverageChecker\Loaders\PhpMnd;
6
7
class PhpMndTest extends TestCase
8
{
9
    private $mnd;
10
11
    public function setUp()
12
    {
13
        $file = __DIR__ . '/../fixtures/phpmnd.txt';
14
        $this->mnd = new PhpMnd($file);
15
16
        $this->assertInstanceOf(PhpMnd::class, $this->mnd);
17
    }
18
19
    public function testGetOutput()
20
    {
21
        $expected = [
22
            'test.php',
23
            'test2.php',
24
        ];
25
26
        $this->assertSame($expected, $this->mnd->parseLines());
27
    }
28
29
    /**
30
     * @dataProvider fileInputs
31
     */
32
    public function testLinesReturnCorrect($filename, $lineNo, $expected)
33
    {
34
        $this->mnd->parseLines();
35
36
        $this->assertSame($expected, $this->mnd->getErrorsOnLine($filename, $lineNo));
37
    }
38
39
    public function testInvalidFile()
40
    {
41
        $this->assertTrue($this->mnd->handleNotFoundFile());
42
    }
43
44
    public function fileInputs()
45
    {
46
        return [
47
            'found file, valid line' => ['test.php', 2, []],
48
            'found file, invalid line' => ['test.php', 3, ['Magic number: 7']],
49
            'file not found' => ['otherFile.php', 2, []],
50
        ];
51
    }
52
}
53