Passed
Pull Request — master (#30)
by Scott
02:25
created

PhpCsReflectionTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 58
rs 10
c 1
b 0
f 0
wmc 4
lcom 1
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
B testRelatedMethods() 0 31 2
A testRelatedMethodsFileNotFound() 0 23 2
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
            var_dump($exception);
0 ignored issues
show
Security Debugging Code introduced by
var_dump($exception); looks like debug code. Are you sure you do not want to remove it? This might expose sensitive data.
Loading history...
60
            $output = ob_get_clean();
61
            $this->assertContains("Can't find file", $output);
62
63
            return true;
64
        }
65
66
        $this->fail('Exception not thrown when Expected');
67
    }
68
}
69