|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of the Superdesk Web Publisher Bridge for the Content API. |
|
5
|
|
|
* |
|
6
|
|
|
* Copyright 2016 Sourcefabric z.u. and contributors. |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please see the |
|
9
|
|
|
* AUTHORS and LICENSE files distributed with this source code. |
|
10
|
|
|
* |
|
11
|
|
|
* @copyright 2016 Sourcefabric z.ú. |
|
12
|
|
|
* @license http://www.superdesk.org/license |
|
13
|
|
|
*/ |
|
14
|
|
|
namespace SWP\Bundle\BridgeBundle\Tests\Functional\app; |
|
15
|
|
|
|
|
16
|
|
|
use Symfony\Component\Config\Loader\LoaderInterface; |
|
17
|
|
|
use Symfony\Component\Filesystem\Filesystem; |
|
18
|
|
|
use Symfony\Component\HttpKernel\Kernel; |
|
19
|
|
|
|
|
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
|
|
|
|