1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Doctrine\Bundle\DoctrineBundle\Tests\DependencyInjection\Fixtures; |
4
|
|
|
|
5
|
|
|
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle; |
6
|
|
|
use Psr\Log\NullLogger; |
7
|
|
|
use Symfony\Bundle\FrameworkBundle\FrameworkBundle; |
8
|
|
|
use Symfony\Component\Config\Loader\LoaderInterface; |
9
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
10
|
|
|
use Symfony\Component\HttpKernel\Kernel; |
11
|
|
|
|
12
|
|
|
class TestKernel extends Kernel |
13
|
|
|
{ |
14
|
|
|
/** @var string|null */ |
15
|
|
|
private $projectDir; |
|
|
|
|
16
|
|
|
|
17
|
|
|
public function __construct() |
18
|
|
|
{ |
19
|
|
|
parent::__construct('test', true); |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
public function registerBundles() : iterable |
23
|
|
|
{ |
24
|
|
|
return [ |
25
|
|
|
new FrameworkBundle(), |
26
|
|
|
new DoctrineBundle(), |
27
|
|
|
]; |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
public function registerContainerConfiguration(LoaderInterface $loader) |
31
|
|
|
{ |
32
|
|
|
$loader->load(static function (ContainerBuilder $container) { |
33
|
|
|
// @todo Setting the kernel.name parameter can be removed once the dependency on DoctrineCacheBundle has been dropped |
34
|
|
|
$container->setParameter('kernel.name', 'foo'); |
35
|
|
|
$container->loadFromExtension('framework', ['secret' => 'F00']); |
36
|
|
|
|
37
|
|
|
$container->loadFromExtension('doctrine', [ |
38
|
|
|
'dbal' => ['driver' => 'pdo_sqlite'], |
39
|
|
|
'orm' => [ |
40
|
|
|
'mappings' => [ |
41
|
|
|
'RepositoryServiceBundle' => [ |
42
|
|
|
'type' => 'annotation', |
43
|
|
|
'dir' => __DIR__ . '/Bundles/RepositoryServiceBundle/Entity', |
44
|
|
|
'prefix' => 'Fixtures\Bundles\RepositoryServiceBundle\Entity', |
45
|
|
|
], |
46
|
|
|
], |
47
|
|
|
], |
48
|
|
|
]); |
49
|
|
|
|
50
|
|
|
// Register a NullLogger to avoid getting the stderr default logger of FrameworkBundle |
51
|
|
|
$container->register('logger', NullLogger::class); |
52
|
|
|
}); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function getProjectDir() : string |
56
|
|
|
{ |
57
|
|
|
if ($this->projectDir === null) { |
58
|
|
|
$this->projectDir = sys_get_temp_dir() . '/sf_kernel_' . md5(mt_rand()); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
return $this->projectDir; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public function getRootDir() : string |
65
|
|
|
{ |
66
|
|
|
return $this->getProjectDir(); |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|