AbstractPageTest::setUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 8
nc 1
nop 0
dl 0
loc 14
ccs 0
cts 11
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * @author Gerard van Helden <[email protected]>
4
 * @copyright Zicht Online <http://zicht.nl>
5
 */
6
7
namespace Zicht\Bundle\PageBundle\Test\Integration;
8
9
use Symfony\Component\HttpFoundation\Request;
10
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
11
use Symfony\Component\HttpKernel\HttpKernelInterface;
12
use Symfony\Component\HttpKernel\KernelEvents;
13
use Zicht\Bundle\PageBundle\Controller\PageController;
14
use Zicht\Bundle\PageBundle\Manager\PageManager;
15
16
/**
17
 * Class AbstractPageTest
18
 *
19
 * @package Zicht\Bundle\PageBundle\Test\Integration
20
 */
21
abstract class AbstractPageTest extends \PHPUnit_Framework_TestCase
22
{
23
    /**
24
     * @var \AppKernel
0 ignored issues
show
Bug introduced by
The type AppKernel was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
25
     */
26
    public $kernel;
27
28
    /**
29
     * @{inheritDoc}
30
     */
31
    public function setUp()
32
    {
33
        $this->kernel = new \AppKernel();
34
        $this->kernel->boot();
35
36
        // we need to synthesize the request, because it could be used by the controller or it's templates.
37
        $request = new Request();
38
39
        $this->kernel->getContainer()->get('event_dispatcher')->dispatch(
40
            KernelEvents::REQUEST,
41
            new GetResponseEvent($this->kernel, $request, HttpKernelInterface::MASTER_REQUEST)
42
        );
43
        $this->kernel->getContainer()->enterScope('request');
44
        $this->kernel->getContainer()->set('request', $request, 'request');
45
    }
46
47
    /**
48
     * Creates page manager
49
     *
50
     * @return PageManager
51
     */
52
    protected function createPageManager()
53
    {
54
        $kernel = new \AppKernel();
55
        $kernel->boot();
56
57
        $pageManager = $kernel->getContainer()->get('zicht_page.page_manager');
58
        return $pageManager;
59
    }
60
61
    /**
62
     * Creates page controller
63
     *
64
     * @return PageController
65
     */
66
    protected function createPageController()
67
    {
68
        $pageController = new PageController();
69
        $pageController->setContainer($this->kernel->getContainer());
70
        return $pageController;
71
    }
72
}
73