Completed
Push — master ( 00ae50...77d591 )
by Narcotic
27:26 queued 18:13
created

GravitonTestCase   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 64.29%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 5
dl 0
loc 52
ccs 9
cts 14
cp 0.6429
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createKernel() 0 16 1
A getSimpleTestDouble() 0 7 1
1
<?php
2
/**
3
 * graviton test case
4
 */
5
6
namespace Graviton\TestBundle\Test;
7
8
use Graviton\AppKernel;
9
use Graviton\BundleBundle\GravitonBundleBundle;
10
use Graviton\BundleBundle\Loader\BundleLoader;
11
use Liip\FunctionalTestBundle\Test\WebTestCase;
12
13
/**
14
 * Graviton test case
15
 *
16
 * Override creating a kernel with our custom bundle-bundle routine.
17
 *
18
 * @author   List of contributors <https://github.com/libgraviton/graviton/graphs/contributors>
19
 * @license  https://opensource.org/licenses/MIT MIT License
20
 * @link     http://swisscom.ch
21
 */
22
class GravitonTestCase extends WebTestCase
23
{
24
25
    use PrivateClassMethodTrait;
26
27
    /**
28
     * return our namespaced AppKernel
29
     *
30
     * Most symfony projects keep their AppKernel class in phps
31
     * global space. Since we don't this needs to be overridden.
32
     *
33
     * This also allows us to properly set up the BundleLoader
34
     * infrastucture. This isn't in the DIC since it is used to
35
     * bootstrap the DIC itself.
36
     *
37
     * @param array $options array of options, default: empty, currently ignored
38
     *
39
     * @return \Graviton\AppKernel
40
     */
41 8
    public static function createKernel(array $options = array())
42
    {
43 8
        include_once __DIR__ . '/../../../../app/AppKernel.php';
44
45 8
        $env = 'test';
46 8
        $debug = false;
47
48 8
        $kernel = new AppKernel($env, $debug);
49 8
        $kernel->setBundleLoader(new BundleLoader(new GravitonBundleBundle()));
50 8
        $kernel->boot();
51
52
        //set error reporting for phpunit
53 8
        ini_set('error_reporting', E_ALL);
54
55 8
        return $kernel;
56
    }
57
58
    /**
59
     * Provides a test double for the named calss.
60
     *
61
     * @param string $class   Full namespace of the class to be doubled
62
     * @param array  $methods List of methods to be doubled
63
     *
64
     * @return \PHPUnit_Framework_MockObject_MockObject
65
     */
66
    public function getSimpleTestDouble($class, array $methods = array())
67
    {
68
        return $this->getMockBuilder($class)
69
            ->disableOriginalConstructor()
70
            ->setMethods($methods)
71
            ->getMock();
72
    }
73
}
74