-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathTestKernel.php
More file actions
93 lines (79 loc) · 3.77 KB
/
TestKernel.php
File metadata and controls
93 lines (79 loc) · 3.77 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
namespace Webfactory\ShortcodeBundle\Tests\Fixtures;
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
use Symfony\Bundle\TwigBundle\TwigBundle;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Kernel;
use Thunder\Shortcode\Handler\PlaceholderHandler;
use Webfactory\ShortcodeBundle\Tests\Fixtures\Controller\InvokableShortcodeTestController;
use Webfactory\ShortcodeBundle\Tests\Fixtures\Controller\ShortcodeTestController;
use Webfactory\ShortcodeBundle\WebfactoryShortcodeBundle;
final class TestKernel extends Kernel
{
public function registerBundles(): array
{
return [
new FrameworkBundle(),
new TwigBundle(),
new WebfactoryShortcodeBundle(),
];
}
public function registerContainerConfiguration(LoaderInterface $loader): void
{
$loader->load(static function (ContainerBuilder $container): void {
$container->loadFromExtension('framework', [
'secret' => 'top-secret',
'test' => true,
'esi' => ['enabled' => true],
'fragments' => ['enabled' => true],
'router' => ['resource' => '%kernel.project_dir%/src/Resources/config/guide-routing.php'],
] + (Kernel::VERSION_ID < 70000 ? ['annotations' => ['enabled' => false]] : []));
$container->loadFromExtension('twig', [
'strict_variables' => true,
]);
$testControllerAction = ShortcodeTestController::class.'::test';
$container->loadFromExtension('webfactory_shortcode', [
'shortcodes' => [
'test-config-inline' => $testControllerAction,
'test-config-esi' => [
'controller' => $testControllerAction,
'method' => 'esi',
],
'test-config-invokable' => InvokableShortcodeTestController::class,
'test-shortcode-guide' => [
'controller' => $testControllerAction,
'description' => "Description for the 'test-shortcode-guide' shortcode",
'example' => 'test-shortcode-guide test=true',
],
],
]);
$container->register(ShortcodeTestController::class)
->setAutoconfigured(true)
->setAutowired(true)
->addTag('controller.service_arguments');
$container->register(InvokableShortcodeTestController::class)
->setAutoconfigured(true)
->setAutowired(true)
->addTag('controller.service_arguments');
// Service definitions from test_shortcodes.xml
$container->setDefinition('test_esi', new ChildDefinition('Webfactory\ShortcodeBundle\Handler\EmbeddedShortcodeHandler.esi'))
->replaceArgument(1, $testControllerAction)
->addTag('webfactory.shortcode', ['shortcode' => 'test-service-esi']);
$container->setDefinition('test_inline', new ChildDefinition('Webfactory\ShortcodeBundle\Handler\EmbeddedShortcodeHandler.inline'))
->replaceArgument(1, $testControllerAction)
->addTag('webfactory.shortcode', ['shortcode' => 'test-service-inline']);
$container->register(PlaceholderHandler::class)
->addTag('webfactory.shortcode', ['shortcode' => 'placeholder']);
});
}
public function getCacheDir(): string
{
return __DIR__.'/var/cache/'.$this->environment;
}
public function getLogDir(): string
{
return __DIR__.'/var/log';
}
}