Skip to content

Commit b52462d

Browse files
committed
Load configuration as PHP
1 parent d49df3d commit b52462d

2 files changed

Lines changed: 43 additions & 40 deletions

File tree

tests/Fixtures/TestKernel.php

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

33
namespace Webfactory\Bundle\PolyglotBundle\Tests\Fixtures;
44

5+
use Doctrine\DBAL\Logging\Middleware;
56
use Symfony\Component\Config\Loader\LoaderInterface;
7+
use Symfony\Component\DependencyInjection\ChildDefinition;
8+
use Symfony\Component\DependencyInjection\ContainerBuilder;
9+
use Symfony\Component\DependencyInjection\Reference;
610
use Symfony\Component\HttpKernel\Kernel;
711

812
class 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

tests/Fixtures/config/config.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)