PsalmDiffFilterTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 24
dl 0
loc 35
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testNoValidLines() 0 18 2
A testValid() 0 12 1
1
<?php
2
namespace exussum12\CoverageChecker\tests;
3
4
use PHPUnit\Framework\TestCase;
5
use Exception;
6
7
/**
8
 * Ignored due to acceptance test needing to write values
9
 * @SuppressWarnings(PHPMD.Superglobals)
10
 */
11
class PsalmDiffFilterTest extends TestCase
12
{
13
14
    public function testValid()
15
    {
16
        $GLOBALS['argv'] = [
17
            'diffFilter',
18
            '--psalm',
19
            __DIR__ . '/fixtures/change.txt',
20
            __DIR__ . '/fixtures/psalm.xml'
21
        ];
22
        ob_start();
23
        require(__DIR__ . "/../src/Runners/generic.php");
24
        $output = ob_get_clean();
25
        $this->assertContains('100.00% Covered', $output);
26
    }
27
28
    public function testNoValidLines()
29
    {
30
        $GLOBALS['argv'] = [
31
            'diffFilter',
32
            '--psalm',
33
            __DIR__ . '/fixtures/change.txt',
34
            __DIR__ . '/fixtures/psalm-change.xml',
35
        ];
36
        try {
37
            ob_start();
38
            require(__DIR__ . "/../src/Runners/generic.php");
39
        } catch (Exception $exception) {
40
            $output = ob_get_clean();
41
            $this->assertEquals(2, $exception->getCode());
42
            $this->assertContains('0.00%', $output);
43
            return;
44
        }
45
        $this->fail("no exception thrown");
46
    }
47
}
48