Passed
Pull Request — master (#16)
by Scott
01:59
created

PhpStanRelatedTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A testRelatedMethods() 0 13 1
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
        $this->expectException(Exception::class);
12
        $GLOBALS['argv'] = [
13
            'diffFilter',
14
            '--phpstan',
15
            '--autoload=' . __DIR__ . 'fixtures/phpstanTypeError.php',
16
            __DIR__ . '/fixtures/change.txt',
17
            __DIR__ . '/fixtures/phpstanTypeError.txt'
18
        ];
19
20
        require(__DIR__ . "/../src/Runners/generic.php");
21
    }
22
}
23