Passed
Push — master ( 31de2d...8df2bc )
by Scott
33s
created

PhpMndTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
1
<?php
2
namespace exussum12\CoverageChecker\tests;
3
4
use PHPUnit\Framework\TestCase;
5
use exussum12\CoverageChecker\PhpMndLoader;
6
7
class PhpMndTest extends TestCase
8
{
9
    public function setUp()
10
    {
11
        $file = __DIR__ . "/fixtures/phpmnd.txt";
12
        $this->mnd = new PhpMndLoader($file);
0 ignored issues
show
Bug introduced by
The property mnd does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
13
14
        $this->assertInstanceOf(PhpMndLoader::class, $this->mnd);
15
    }
16
17
    public function testGetOutput()
18
    {
19
        $expected = [
20
            'test.php' => [
21
                3 => 'Magic number: 7',
22
                4 => 'Magic number: 12',
23
            ],
24
            'test2.php' => [
25
                3 => 'Magic number: 7',
26
                4 => 'Magic number: 12',
27
            ],
28
        ];
29
30
        $this->assertSame($expected, $this->mnd->getLines());
31
    }
32
33
    /**
34
     * @dataProvider fileInputs
35
     */
36
    public function testLinesReturnCorrect($filename, $lineNo, $expected)
37
    {
38
        $this->mnd->getLines();
39
40
        $this->assertSame($expected, $this->mnd->isValidLine($filename, $lineNo));
41
    }
42
43
    public function testInvalidFile()
44
    {
45
        $this->assertTrue($this->mnd->handleNotFoundFile());
46
    }
47
48
    public function fileInputs()
49
    {
50
        return [
51
            'found file, valid line' => ['test.php', 2, true],
52
            'found file, invalid line' => ['test.php', 3, false],
53
            'file not found' => ['otherFile.php', 2, true],
54
        ];
55
    }
56
}
57