FileMapperTest::testDoesNotExist()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
namespace exussum12\CoverageChecker\tests\FileMatchers;
3
4
use PHPUnit\Framework\TestCase;
5
use exussum12\CoverageChecker\Exceptions\FileNotFound;
6
use exussum12\CoverageChecker\FileMatchers\FileMapper;
7
8
class FileMapperTest extends TestCase
9
{
10
    public function testPrefix()
11
    {
12
        $fileMapper = new FileMapper('unwantedPrefix', '/home/person/code');
13
        $needle = "unwantedPrefix/file.php";
14
        $haystack = [
15
            '/home/person/code/someOtherFile.php',
16
            '/home/person/code/longer/file.php',
17
            '/home/person/code/file.php',
18
19
        ];
20
21
        $this->assertEquals(
22
            '/home/person/code/file.php',
23
            $fileMapper->match($needle, $haystack)
24
        );
25
    }
26
27
    public function testDoesNotExist()
28
    {
29
        $this->expectException(FileNotFound::class);
30
        $fileMapper = new FileMapper('prefix', '/full/path');
31
        $needle = "fileDoesNotExist.php";
32
        $haystack = [];
33
34
        $fileMapper->match($needle, $haystack);
35
    }
36
}
37