22
33namespace Webfactory \Bundle \PolyglotBundle \Tests \Fixtures ;
44
5+ use Doctrine \DBAL \Logging \Middleware ;
56use Symfony \Component \Config \Loader \LoaderInterface ;
7+ use Symfony \Component \DependencyInjection \ChildDefinition ;
8+ use Symfony \Component \DependencyInjection \ContainerBuilder ;
9+ use Symfony \Component \DependencyInjection \Reference ;
610use Symfony \Component \HttpKernel \Kernel ;
711
812class TestKernel extends Kernel
@@ -18,7 +22,45 @@ public function registerBundles(): iterable
1822
1923 public function registerContainerConfiguration (LoaderInterface $ loader ): void
2024 {
21- $ loader ->load (__DIR__ .'/config/config.yml ' );
25+ $ loader ->load (static function (ContainerBuilder $ container ): void {
26+ // Framework configuration
27+ $ container ->loadFromExtension ('framework ' , [
28+ 'test ' => true ,
29+ ] + (Kernel::VERSION_ID < 70000 ? ['annotations ' => ['enabled ' => false ]] : []));
30+
31+ // Webfactory Polyglot Bundle configuration
32+ $ container ->loadFromExtension ('webfactory_polyglot ' , [
33+ 'defaultLocale ' => 'en_GB ' ,
34+ ]);
35+
36+ // Doctrine configuration
37+ $ container ->loadFromExtension ('doctrine ' , [
38+ 'dbal ' => [
39+ 'driver ' => 'pdo_sqlite ' ,
40+ 'memory ' => true ,
41+ ],
42+ 'orm ' => [
43+ 'mappings ' => [
44+ 'WebfactoryPolyglotBundle ' => [
45+ 'type ' => 'attribute ' ,
46+ 'dir ' => '../tests/Fixtures/Entity ' ,
47+ 'prefix ' => 'Webfactory\Bundle\PolyglotBundle\Tests\Fixtures\Entity ' ,
48+ ],
49+ ],
50+ ],
51+ ]);
52+
53+ // Service definitions
54+ $ container ->setDefinition ('entity_manager_for_loading ' , new ChildDefinition ('doctrine.orm.entity_manager ' ));
55+
56+ $ container ->register (QueryLogger::class);
57+
58+ $ container ->register (Middleware::class)
59+ ->setArguments ([
60+ '$logger ' => new Reference (QueryLogger::class),
61+ ])
62+ ->addTag ('doctrine.middleware ' );
63+ });
2264 }
2365
2466 public function getProjectDir (): string
0 commit comments