Completed
Pull Request — master (#30)
by Scott
02:51
created

testRelatedMethodsFileNotFound()   A

Complexity

Conditions 2
Paths 3

Size

Total Lines 22
Code Lines 15

Duplication

Lines 22
Ratio 100 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 2
eloc 15
nc 3
nop 0
dl 22
loc 22
rs 9.2
c 1
b 1
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 View Code Duplication
    public function testRelatedMethodsFileNotFound()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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