ContainerAwareUnitTestCase   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 31
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUpBeforeClass() 0 15 3
A get() 0 3 1
A getParameter() 0 3 1
1
<?php
2
3
namespace BWC\Share\PHPUnit;
4
5
use Symfony\Component\HttpKernel\KernelInterface;
6
7
class ContainerAwareUnitTestCase extends \PHPUnit_Framework_TestCase
8
{
9
    /** @var KernelInterface */
10
    protected static $kernel;
11
    protected static $container;
12
13
    public static function setUpBeforeClass() {
14
        //require_once __DIR__ . '/../../../../../../app/AppKernel.php';
15
        $path = '/../app/AppKernel.php';
16
        for ($i=0; $i<15; $i++) {
17
            $file = __DIR__ .$path;
18
            if (is_file($file)) {
19
                require_once $file;
20
                break;
21
            }
22
            $path = '/..'.$path;
23
        }
24
        self::$kernel = new \AppKernel('test', true);
0 ignored issues
show
Documentation Bug introduced by
It seems like new \AppKernel('test', true) of type object<AppKernel> is incompatible with the declared type object<Symfony\Component...Kernel\KernelInterface> of property $kernel.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
25
        self::$kernel->boot();
26
        self::$container = self::$kernel->getContainer();
27
    }
28
29
    public function get($serviceId) {
30
        return self::$kernel->getContainer()->get($serviceId);
31
    }
32
33
    public function getParameter($name) {
34
        return self::$kernel->getContainer()->getParameter($name);
35
    }
36
37
}
38