1 | <?php |
||
20 | class AppKernel extends Kernel |
||
21 | { |
||
22 | private $testCase; |
||
23 | private $rootConfig; |
||
24 | |||
25 | public function __construct($testCase, $rootConfig, $environment, $debug) |
||
26 | { |
||
27 | if (!is_dir(__DIR__.'/'.$testCase)) { |
||
28 | throw new \InvalidArgumentException(sprintf('The test case "%s" does not exist.', $testCase)); |
||
29 | } |
||
30 | |||
31 | $this->testCase = $testCase; |
||
32 | $fs = new Filesystem(); |
||
33 | if (!$fs->isAbsolutePath($rootConfig) && !file_exists($rootConfig = __DIR__.'/'.$testCase.'/'.$rootConfig)) { |
||
34 | throw new \InvalidArgumentException(sprintf('The root config "%s" does not exist.', $rootConfig)); |
||
35 | } |
||
36 | |||
37 | $this->rootConfig = $rootConfig; |
||
38 | parent::__construct($environment, $debug); |
||
39 | } |
||
40 | |||
41 | public function registerBundles() |
||
42 | { |
||
43 | if (!file_exists($filename = $this->getRootDir().'/'.$this->testCase.'/bundles.php')) { |
||
44 | throw new \RuntimeException(sprintf('The bundles file "%s" does not exist.', $filename)); |
||
45 | } |
||
46 | |||
47 | return include $filename; |
||
48 | } |
||
49 | |||
50 | public function registerContainerConfiguration(LoaderInterface $loader) |
||
51 | { |
||
52 | $loader->load($this->rootConfig); |
||
53 | } |
||
54 | |||
55 | protected function getKernelParameters() |
||
56 | { |
||
57 | $parameters = parent::getKernelParameters(); |
||
58 | $parameters['kernel.test_case'] = $this->testCase; |
||
59 | |||
60 | return $parameters; |
||
61 | } |
||
62 | } |
||
63 |