PhpCsReflectionTest::testRelatedMethods()   A
last analyzed

Complexity

Conditions 2
Paths 3

Size

Total Lines 30
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 19
nc 3
nop 0
dl 0
loc 30
rs 9.6333
c 0
b 0
f 0
1
<?php
2
namespace exussum12\CoverageChecker\tests;
3
4
use Exception;
5
use PHPUnit\Framework\TestCase;
6
7
/**
8
 * Ignored due to acceptance test needing to write values
9
 * @SuppressWarnings(PHPMD.Superglobals)
10
 */
11
class PhpCsReflectionTest extends TestCase
12
{
13
    public function testRelatedMethods()
14
    {
15
        $GLOBALS['argv'] = [
16
            'diffFilter',
17
            '--phpcs',
18
            '--report=json',
19
            __DIR__ . '/fixtures/DocBlocks.txt',
20
            __DIR__ . '/fixtures/DocBlocks.json'
21
        ];
22
23
        try {
24
            ob_start();
25
            require(__DIR__ . "/../src/Runners/generic.php");
26
        } catch (Exception $exception) {
27
            $output = json_decode(ob_get_clean());
28
            $file = $output->violations->{'DocBlocks.php'};
29
            $this->assertEquals(
30
                14,
31
                count($file)
32
            );
33
34
            $this->assertEquals(
35
                5,
36
                count($file[12]->message)
37
            );
38
39
            return true;
40
        }
41
42
        $this->fail('Exception not thrown when Expected');
43
    }
44
45
    public function testRelatedMethodsFileNotFound()
46
    {
47
        $GLOBALS['argv'] = [
48
            'diffFilter',
49
            '--phpcs',
50
            '--report=json',
51
            __DIR__ . '/fixtures/DocBlocks.txt',
52
            __DIR__ . '/fixtures/DocBlocksNotFound.json'
53
        ];
54
55
        try {
56
            ob_start();
57
            require(__DIR__ . "/../src/Runners/generic.php");
58
        } catch (Exception $exception) {
59
            $output = ob_get_clean();
60
            $this->assertContains("Can't find file", $output);
61
62
            return true;
63
        }
64
65
        $this->fail('Exception not thrown when Expected');
66
    }
67
}
68