Passed
Push — master ( 8df2bc...bb46b9 )
by Scott
36s
created

PhpunitFilterTest::testOutputOfGetTests()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 15
nc 1
nop 0
dl 0
loc 23
rs 9.0856
c 0
b 0
f 0
1
<?php
2
namespace exussum12\CoverageChecker\tests;
3
4
use exussum12\CoverageChecker\PhpunitFilter;
5
use PHPUnit\Framework\TestCase;
6
use exussum12\CoverageChecker\DiffFileLoader;
7
use exussum12\CoverageChecker\FileMatchers;
8
use Exception;
9
10
class PhpunitFilterTest extends TestCase
11
{
12
    protected $coverage;
13
    protected $diff;
14
    protected $matcher;
15
16
    public function setUp()
17
    {
18
        $this->coverage = __DIR__ . '/fixtures/php-coverage.php';
19
        $this->diff = new DiffFileLoader(__DIR__ . '/fixtures/change.txt');
20
        $this->matcher = new FileMatchers\EndsWith();
21
    }
22
    public function testBadFilesPassedIn()
23
    {
24
        $this->expectException(Exception::class);
25
        $badFile = 'doesNotExist.blah';
26
        new PhpunitFilter(
27
            $this->diff,
28
            $this->matcher,
29
            $badFile
30
        );
31
    }
32
33
    public function testOutputOfGetTests()
34
    {
35
        $this->diff = new DiffFileLoader(__DIR__ . '/fixtures/coverageMatchFiles.txt');
36
        $coverage = new PhpunitFilter(
37
            $this->diff,
38
            $this->matcher,
39
            $this->coverage
40
        );
41
42
        $expected = [
43
            'exussum12\CoverageChecker\tests\ArgParserTest' => [
44
                'testNumericArgs',
45
            ],
46
            'exussum12\CoverageChecker\tests\GenericDiffFilterTest' => [
47
                'testValid',
48
                'testMissingHandler',
49
            ],
50
            'exussum12\CoverageChecker\tests\PhpcsDiffFilterTest' => [
51
                'testValid',
52
            ],
53
        ];
54
        $this->assertEquals($expected, $coverage->getTestsForRunning());
55
    }
56
57
    public function testUnknownDiffFiles()
58
    {
59
        $this->diff = new DiffFileLoader(__DIR__ . '/fixtures/coverageMatchUnknownFiles.txt');
60
        $coverage = new PhpunitFilter(
61
            $this->diff,
62
            $this->matcher,
63
            $this->coverage
64
        );
65
        $expected = [
66
            'tests\Unknown' => [''],
67
        ];
68
        $this->assertEquals($expected, $coverage->getTestsForRunning());
69
    }
70
}