Passed
Pull Request — master (#11)
by Pavel
07:02
created

TestKernel::getCacheDir()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Bankiru\Api\JsonRpc\Test\Kernel;
4
5
use Bankiru\Api\JsonRpc\BankiruJsonRpcServerBundle;
6
use Bankiru\Api\JsonRpc\Test\JsonRpcTestBundle;
7
use Bankiru\Api\Rpc\BankiruRpcServerBundle;
8
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
9
use JMS\SerializerBundle\JMSSerializerBundle;
10
use Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle;
11
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
12
use Symfony\Bundle\SecurityBundle\SecurityBundle;
13
use Symfony\Component\Config\Loader\LoaderInterface;
14
use Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest;
15
16
final class TestKernel extends KernelForTest
17
{
18 15
    public function registerBundles()
19
    {
20
        $bundles = [
21 15
            new FrameworkBundle(),
22 15
            new SecurityBundle(),
23 15
            new SensioFrameworkExtraBundle(),
24 15
            new BankiruRpcServerBundle(),
25 15
            new BankiruJsonRpcServerBundle(),
26 15
            new JsonRpcTestBundle(),
27 15
        ];
28
29 15
        if (false !== getenv('JMS_BUNDLE')) {
30 15
            $bundles[] = new JMSSerializerBundle();
31 15
        }
32
33 15
        if (false !== getenv('DOCTRINE_BUNDLE')) {
34 15
            $bundles[] = new DoctrineBundle();
35 15
        }
36
37 15
        return $bundles;
38
    }
39
40 15
    public function getCacheDir()
41
    {
42 15
        return __DIR__ . '/../../build/' . $this->getName() . '/cache';
43
    }
44
45 1
    public function getLogDir()
46
    {
47 1
        return __DIR__ . '/../../build/' . $this->getName() . '/log';
48
    }
49
50 1
    public function registerContainerConfiguration(LoaderInterface $loader)
51
    {
52 1
        $loader->load(__DIR__ . '/config.yml');
53
54 1
        if (false !== getenv('JMS_BUNDLE')) {
55 1
            $loader->load(__DIR__ . '/config_jms.yml');
56 1
        }
57
58 1
        if (false !== getenv('DOCTRINE_BUNDLE')) {
59 1
            $loader->load(__DIR__ . '/config_doctrine.yml');
60 1
        }
61 1
    }
62
63 15
    public function getName()
64
    {
65 15
        $name = 'jsorpc_test';
66
67 15
        if (false !== getenv('JMS_BUNDLE')) {
68 15
            $name .= '_jms';
69 15
        }
70
71 15
        if (false !== getenv('DOCTRINE_BUNDLE')) {
72 15
            $name .= '_doctrine';
73 15
        }
74
75 15
        return $name;
76
    }
77
78
    public function getEnvironment()
79
    {
80
        return 'test';
81
    }
82
}
83