Passed
Push — master ( 4c8245...5bb496 )
by Scott
02:18
created

DiffFileLoaderOldVersionTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 50
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 2

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testDiffResultsMatch() 0 6 1
B getResults() 0 31 1
A getChangedLines() 0 5 1
1
<?php
2
namespace exussum12\CoverageChecker\tests;
3
4
use exussum12\CoverageChecker\DiffFileLoaderOldVersion;
5
use PHPUnit\Framework\TestCase;
6
7
class DiffFileLoaderOldVersionTest extends TestCase
8
{
9
    /**
10
     * @dataProvider getResults
11
     */
12
    public function testDiffResultsMatch($file, $expected)
13
    {
14
        $changed = $this->getChangedLines($file);
15
16
        $this->assertEquals($expected, $changed);
17
    }
18
19
    public function getResults()
20
    {
21
        return [
22
            'newFile' => [
23
                __DIR__ . '/fixtures/newFile.txt',
24
                [
25
                    'dev/null' => [-1]
26
                ]
27
            ],
28
            'lineChange' => [
29
                __DIR__ . '/fixtures/change.txt',
30
                [
31
                    'changedFile.php' => [3]
32
                ]
33
            ],
34
             'multipleFiles' => [
35
                 __DIR__ . '/fixtures/multiple.txt',
36
                 [
37
                     'changedFile.php' => [3],
38
                     'dev/null' => [-1],
39
                     'deletedFile.php' => [1,2,3]
40
                 ]
41
             ],
42
             'removeFile' => [
43
                 __DIR__ . '/fixtures/removeFile.txt',
44
                 [
45
                     'deletedFile.php' => [1,2,3]
46
                 ]
47
             ],
48
        ];
49
    }
50
51
    private function getChangedLines($file)
52
    {
53
        $fileLoader = new DiffFileLoaderOldVersion($file);
54
        return $fileLoader->getChangedLines();
55
    }
56
}
57