Completed
Push — master ( 3f2b6b...56185f )
by Scott
06:20
created

PhpStanRelatedTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A testRelatedMethods() 0 21 2
1
<?php
2
namespace exussum12\CoverageChecker\tests;
3
4
use Exception;
5
use PHPUnit\Framework\TestCase;
6
7
class PhpStanRelatedTest extends TestCase
8
{
9
    public function testRelatedMethods()
0 ignored issues
show
Coding Style introduced by
testRelatedMethods uses the super-global variable $GLOBALS which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
10
    {
11
        $GLOBALS['argv'] = [
12
            'diffFilter',
13
            '--phpstan',
14
            '--autoload=' . __DIR__ . '/fixtures/phpstanTypeError.php',
15
            __DIR__ . '/fixtures/addTypeError.txt',
16
            __DIR__ . '/fixtures/phpstanTypeError.txt'
17
        ];
18
19
        try {
20
            ob_start();
21
            require(__DIR__ . "/../src/Runners/generic.php");
22
        } catch (Exception $exception) {
23
            $output = ob_get_clean();
24
            $this->assertContains('used test.php', $output);
25
            return true;
26
        }
27
28
        $this->fail('Exception not thrown when Expected');
29
    }
30
}
31