-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTestKernel.php
More file actions
70 lines (60 loc) · 2.4 KB
/
TestKernel.php
File metadata and controls
70 lines (60 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
namespace Webfactory\Bundle\PolyglotBundle\Tests\Fixtures;
use Doctrine\DBAL\Logging\Middleware;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\HttpKernel\Kernel;
class TestKernel extends Kernel
{
public function registerBundles(): iterable
{
return [
new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new \Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new \Webfactory\Bundle\PolyglotBundle\WebfactoryPolyglotBundle(),
];
}
public function registerContainerConfiguration(LoaderInterface $loader): void
{
$loader->load(static function (ContainerBuilder $container): void {
// Framework configuration
$container->loadFromExtension('framework', [
'test' => true,
] + (Kernel::VERSION_ID < 70000 ? ['annotations' => ['enabled' => false]] : []));
// Webfactory Polyglot Bundle configuration
$container->loadFromExtension('webfactory_polyglot', [
'defaultLocale' => 'en_GB',
]);
// Doctrine configuration
$container->loadFromExtension('doctrine', [
'dbal' => [
'driver' => 'pdo_sqlite',
'memory' => true,
],
'orm' => [
'mappings' => [
'WebfactoryPolyglotBundle' => [
'type' => 'attribute',
'dir' => '../tests/Fixtures/Entity',
'prefix' => 'Webfactory\Bundle\PolyglotBundle\Tests\Fixtures\Entity',
],
],
],
]);
// Service definitions
$container->setDefinition('entity_manager_for_loading', new ChildDefinition('doctrine.orm.entity_manager'));
$container->register(QueryLogger::class);
$container->register(Middleware::class)
->setArguments([
'$logger' => new Reference(QueryLogger::class),
])
->addTag('doctrine.middleware');
});
}
public function getProjectDir(): string
{
return __DIR__;
}
}