55use Symfony \Bundle \FrameworkBundle \FrameworkBundle ;
66use Symfony \Bundle \TwigBundle \TwigBundle ;
77use Symfony \Component \Config \Loader \LoaderInterface ;
8+ use Symfony \Component \DependencyInjection \ChildDefinition ;
9+ use Symfony \Component \DependencyInjection \ContainerBuilder ;
810use Symfony \Component \HttpKernel \Kernel ;
11+ use Thunder \Shortcode \Handler \PlaceholderHandler ;
12+ use Webfactory \ShortcodeBundle \Tests \Fixtures \Controller \InvokableShortcodeTestController ;
13+ use Webfactory \ShortcodeBundle \Tests \Fixtures \Controller \ShortcodeTestController ;
914use Webfactory \ShortcodeBundle \WebfactoryShortcodeBundle ;
1015
1116final class TestKernel extends Kernel
@@ -21,17 +26,68 @@ public function registerBundles(): array
2126
2227 public function registerContainerConfiguration (LoaderInterface $ loader ): void
2328 {
24- $ loader ->load (__DIR__ .'/config/config.yml ' );
25- $ loader ->load (__DIR__ .'/config/test_shortcodes.xml ' );
29+ $ loader ->load (static function (ContainerBuilder $ container ): void {
30+ $ container ->loadFromExtension ('framework ' , [
31+ 'secret ' => 'top-secret ' ,
32+ 'test ' => true ,
33+ 'esi ' => ['enabled ' => true ],
34+ 'fragments ' => ['enabled ' => true ],
35+ 'router ' => ['resource ' => '%kernel.project_dir%/src/Resources/config/guide-routing.xml ' ],
36+ ] + (Kernel::VERSION_ID < 70000 ? ['annotations ' => ['enabled ' => false ]] : []));
37+
38+ $ container ->loadFromExtension ('twig ' , [
39+ 'strict_variables ' => true ,
40+ ]);
41+
42+ $ testControllerAction = ShortcodeTestController::class.'::test ' ;
43+
44+ $ container ->loadFromExtension ('webfactory_shortcode ' , [
45+ 'shortcodes ' => [
46+ 'test-config-inline ' => $ testControllerAction ,
47+ 'test-config-esi ' => [
48+ 'controller ' => $ testControllerAction ,
49+ 'method ' => 'esi ' ,
50+ ],
51+ 'test-config-invokable ' => InvokableShortcodeTestController::class,
52+ 'test-shortcode-guide ' => [
53+ 'controller ' => $ testControllerAction ,
54+ 'description ' => "Description for the 'test-shortcode-guide' shortcode " ,
55+ 'example ' => 'test-shortcode-guide test=true ' ,
56+ ],
57+ ],
58+ ]);
59+
60+ $ container ->register (\Webfactory \ShortcodeBundle \Tests \Fixtures \Controller \ShortcodeTestController::class)
61+ ->setAutoconfigured (true )
62+ ->setAutowired (true )
63+ ->addTag ('controller.service_arguments ' );
64+
65+ $ container ->register (\Webfactory \ShortcodeBundle \Tests \Fixtures \Controller \InvokableShortcodeTestController::class)
66+ ->setAutoconfigured (true )
67+ ->setAutowired (true )
68+ ->addTag ('controller.service_arguments ' );
69+
70+ // Service definitions from test_shortcodes.xml
71+ $ container ->setDefinition ('test_esi ' , new ChildDefinition ('Webfactory\ShortcodeBundle\Handler\EmbeddedShortcodeHandler.esi ' ))
72+ ->replaceArgument (1 , $ testControllerAction )
73+ ->addTag ('webfactory.shortcode ' , ['shortcode ' => 'test-service-esi ' ]);
74+
75+ $ container ->setDefinition ('test_inline ' , new ChildDefinition ('Webfactory\ShortcodeBundle\Handler\EmbeddedShortcodeHandler.inline ' ))
76+ ->replaceArgument (1 , $ testControllerAction )
77+ ->addTag ('webfactory.shortcode ' , ['shortcode ' => 'test-service-inline ' ]);
78+
79+ $ container ->register (PlaceholderHandler::class)
80+ ->addTag ('webfactory.shortcode ' , ['shortcode ' => 'placeholder ' ]);
81+ });
2682 }
2783
2884 public function getCacheDir (): string
2985 {
30- return __DIR__ .'/cache/ ' .$ this ->environment ;
86+ return __DIR__ .'/var/ cache/ ' .$ this ->environment ;
3187 }
3288
3389 public function getLogDir (): string
3490 {
35- return __DIR__ .'/logs ' ;
91+ return __DIR__ .'/var/log ' ;
3692 }
3793}
0 commit comments