|
1
|
|
|
<?php declare(strict_types = 1); |
|
2
|
|
|
|
|
3
|
|
|
namespace TomCizek\SymfonyProoph\Tests; |
|
4
|
|
|
|
|
5
|
|
|
use Symfony\Component\Config\Loader\LoaderInterface; |
|
6
|
|
|
use Symfony\Component\HttpKernel\Bundle\BundleInterface; |
|
7
|
|
|
use Symfony\Component\HttpKernel\Kernel; |
|
8
|
|
|
use TomCizek\SymfonyInteropContainer\Tests\Configurators\ConfigFile; |
|
9
|
|
|
|
|
10
|
|
|
class TestKernel extends Kernel |
|
11
|
|
|
{ |
|
12
|
|
|
/** @var string[] */ |
|
13
|
|
|
private $bundlesToRegister = []; |
|
14
|
|
|
|
|
15
|
|
|
/** @var ConfigFile[] */ |
|
16
|
|
|
private $configFilesToAdd = []; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* @param string[] $classNames |
|
20
|
|
|
*/ |
|
21
|
|
|
public function addBundleClasses(array $classNames): void |
|
22
|
|
|
{ |
|
23
|
|
|
foreach ($classNames as $className) { |
|
24
|
|
|
$this->addBundleClass($className); |
|
25
|
|
|
} |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
public function addBundleClass(string $className): void |
|
29
|
|
|
{ |
|
30
|
|
|
$this->bundlesToRegister[] = $className; |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @param ConfigFile[] $configFiles |
|
35
|
|
|
*/ |
|
36
|
|
|
public function addConfigFiles(array $configFiles): void |
|
37
|
|
|
{ |
|
38
|
|
|
foreach ($configFiles as $configFile) { |
|
39
|
|
|
$this->addConfigFile($configFile); |
|
40
|
|
|
} |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
public function addConfigFile(ConfigFile $configFile): void |
|
44
|
|
|
{ |
|
45
|
|
|
$this->configFilesToAdd[] = $configFile; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* Returns an array of bundles to register. |
|
50
|
|
|
* @return BundleInterface[] An array of bundle instances |
|
51
|
|
|
*/ |
|
52
|
|
|
public function registerBundles() |
|
53
|
|
|
{ |
|
54
|
|
|
$instances = []; |
|
55
|
|
|
foreach ($this->bundlesToRegister as $className) { |
|
56
|
|
|
$instances[] = new $className(); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
return $instances; |
|
60
|
|
|
|
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* Loads the container configuration. |
|
65
|
|
|
* |
|
66
|
|
|
* @param LoaderInterface $loader A LoaderInterface instance |
|
67
|
|
|
*/ |
|
68
|
|
|
public function registerContainerConfiguration(LoaderInterface $loader) |
|
69
|
|
|
{ |
|
70
|
|
|
foreach ($this->configFilesToAdd as $configFileToAdd) { |
|
71
|
|
|
|
|
72
|
|
|
$loader->load($configFileToAdd->getPath(), $configFileToAdd->getType()); |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
|