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

PhpStanRelatedTest::testRelatedMethods()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 9
nc 1
nop 0
dl 0
loc 13
rs 9.4285
c 1
b 0
f 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