1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of php-task library. |
5
|
|
|
* |
6
|
|
|
* (c) php-task |
7
|
|
|
* |
8
|
|
|
* This source file is subject to the MIT license that is bundled |
9
|
|
|
* with this source code in the file LICENSE. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle; |
13
|
|
|
use Symfony\Bundle\FrameworkBundle\FrameworkBundle; |
14
|
|
|
use Symfony\Component\Config\FileLocator; |
15
|
|
|
use Symfony\Component\Config\Loader\LoaderInterface; |
16
|
|
|
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; |
17
|
|
|
use Symfony\Component\HttpKernel\Kernel; |
18
|
|
|
use Task\TaskBundle\TaskBundle; |
19
|
|
|
|
20
|
|
|
class TestKernel extends Kernel |
21
|
|
|
{ |
22
|
|
|
const STORAGE_VAR_NAME = 'STORAGE'; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @var string |
26
|
|
|
*/ |
27
|
|
|
private $storage; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* {@inheritdoc} |
31
|
|
|
*/ |
32
|
|
|
public function registerBundles() |
33
|
|
|
{ |
34
|
|
|
return [ |
35
|
|
|
new FrameworkBundle(), |
36
|
|
|
new DoctrineBundle(), |
37
|
|
|
new TaskBundle(), |
38
|
|
|
]; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* {@inheritdoc} |
43
|
|
|
*/ |
44
|
|
|
public function registerContainerConfiguration(LoaderInterface $loader) |
45
|
|
|
{ |
46
|
|
|
$this->storage = getenv(self::STORAGE_VAR_NAME); |
47
|
|
|
if ($this->storage === false) { |
48
|
|
|
$this->storage = 'array'; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
$loader->load(sprintf('%s/config/config.yml', __DIR__)); |
52
|
|
|
$loader->load(sprintf('%s/config/config.%s.yml', __DIR__, $this->storage)); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* {@inheritdoc} |
57
|
|
|
*/ |
58
|
|
|
protected function buildContainer() |
59
|
|
|
{ |
60
|
|
|
$container = parent::buildContainer(); |
61
|
|
|
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/config')); |
62
|
|
|
$loader->load('services.xml'); |
63
|
|
|
|
64
|
|
|
$container->setParameter('kernel.storage', $this->storage); |
65
|
|
|
|
66
|
|
|
return $container; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* {@inheritdoc} |
71
|
|
|
*/ |
72
|
|
|
protected function initializeContainer() |
73
|
|
|
{ |
74
|
|
|
$fresh = false; |
75
|
|
|
|
76
|
|
|
$container = $this->buildContainer(); |
77
|
|
|
$container->compile(); |
78
|
|
|
|
79
|
|
|
$this->container = $container; |
80
|
|
|
$this->container->set('kernel', $this); |
81
|
|
|
|
82
|
|
|
if (!$fresh && $this->container->has('cache_warmer')) { |
83
|
|
|
$this->container->get('cache_warmer')->warmUp($this->container->getParameter('kernel.cache_dir')); |
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|