Completed
Push — master ( b3c0e0...bf06df )
by Mewes
02:19
created

AppKernel::__construct()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 15
rs 9.4285
c 1
b 0
f 0
cc 3
eloc 8
nc 4
nop 1
1
<?php
2
3
namespace MewesK\TwigExcelBundle\Tests\Kernel;
4
5
use Symfony\Component\Filesystem\Filesystem;
6
use Symfony\Component\Config\Loader\LoaderInterface;
7
use Symfony\Component\HttpKernel\Kernel;
8
9
/**
10
 * Class AppKernel
11
 * @package MewesK\TwigExcelBundle\Tests\Functional
12
 */
13
class AppKernel extends Kernel
14
{
15
    /**
16
     * @var string
17
     */
18
    private $config;
19
20
    /**
21
     * @param string $config
22
     * @throws \RuntimeException
23
     */
24
    public function __construct($config)
25
    {
26
        parent::__construct('test', true);
27
28
        $fs = new Filesystem();
29
        if (!$fs->isAbsolutePath($config)) {
30
            $config = __DIR__ . '/config/' .$config;
31
        }
32
33
        if (!file_exists($config)) {
34
            throw new \RuntimeException(sprintf('The config file "%s" does not exist.', $config));
35
        }
36
37
        $this->config = $config;
38
    }
39
40
    /**
41
     * @return array
42
     */
43
    public function registerBundles()
44
    {
45
        return [
46
            new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
47
            new \Symfony\Bundle\TwigBundle\TwigBundle(),
48
            new \Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
49
            new \MewesK\TwigExcelBundle\MewesKTwigExcelBundle(),
50
            new \MewesK\TwigExcelBundle\Tests\Functional\TestBundle\TestBundle()
51
        ];
52
    }
53
54
    /**
55
     * @param LoaderInterface $loader
56
     * @throws \Exception
57
     */
58
    public function registerContainerConfiguration(LoaderInterface $loader)
59
    {
60
        $loader->load($this->config);
61
    }
62
63
    /**
64
     * @return string
65
     */
66
    public function getCacheDir()
67
    {
68
        return __DIR__ . '/../../tmp/functional';
69
    }
70
71
    /**
72
     * @return string
73
     */
74
    public function getLogDir()
75
    {
76
        return __DIR__ . '/../../tmp/functional/logs';
77
    }
78
}
79