Code Duplication    Length = 28-29 lines in 2 locations

tests/FileMatchers/FileMapperTest.php 1 location

@@ 8-36 (lines=29) @@
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

tests/FileMatchers/PrefixTest.php 1 location

@@ 8-35 (lines=28) @@
5
use exussum12\CoverageChecker\Exceptions\FileNotFound;
6
use exussum12\CoverageChecker\FileMatchers\Prefix;
7
8
class PrefixTest extends TestCase
9
{
10
    public function testPrefix()
11
    {
12
        $prefixMatcher = new Prefix('/full/path/to/');
13
        $needle = "file.php";
14
        $haystack = [
15
            '/full/path/to/someOtherFile.php',
16
            '/full/path/to/longer/file.php',
17
            '/full/path/to/file.php',
18
        ];
19
20
        $this->assertEquals(
21
            '/full/path/to/file.php',
22
            $prefixMatcher->match($needle, $haystack)
23
        );
24
    }
25
26
    public function testDoesNotExist()
27
    {
28
        $this->expectException(FileNotFound::class);
29
        $prefixMatcher = new Prefix('/full/path/to/');
30
        $needle = "fileDoesNotExist.php";
31
        $haystack = [];
32
33
        $prefixMatcher->match($needle, $haystack);
34
    }
35
}
36