-
Notifications
You must be signed in to change notification settings - Fork 4
DI-test-autowiring #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@chalasr If you have some times, did you know how to fix that test? 🤔 Help to debug, trace: 1) Lexik\Bundle\CronFileGeneratorBundle\Tests\DependencyInjection\LexikCronFileGeneratorExtensionTest::testLoadEmptyConfiguration
Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: You have requested a non-existent service "twig.loader". |
@Spike31 here you go: diff --git a/Tests/DependencyInjection/LexikCronFileGeneratorExtensionTest.php b/Tests/DependencyInjection/LexikCronFileGeneratorExtensionTest.php
index 10929db..05b4d5a 100644
--- a/Tests/DependencyInjection/LexikCronFileGeneratorExtensionTest.php
+++ b/Tests/DependencyInjection/LexikCronFileGeneratorExtensionTest.php
@@ -11,9 +11,11 @@ use Symfony\Bundle\FrameworkBundle\DependencyInjection\FrameworkExtension;
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
use Symfony\Bundle\TwigBundle\DependencyInjection\TwigExtension;
use Symfony\Bundle\TwigBundle\TwigBundle;
+use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
+use Symfony\Component\HttpKernel\Kernel;
class LexikCronFileGeneratorExtensionTest extends TestCase
{
@@ -60,8 +62,7 @@ class LexikCronFileGeneratorExtensionTest extends TestCase
->setAutowired(true);
$this->compileContainer($container);
-dd($container->get('templating'));
- $autowired = $container->get('autowired');
+ $this->assertInstanceOf(Autowired::class, $container->get('autowired'));
}
private function createContainer(array $configs = [])
@@ -82,6 +83,14 @@ dd($container->get('templating'));
],
]));
+ $container->set('kernel', new class ('test', false) extends Kernel {
+ public function registerBundles()
+ {
+ }
+ public function registerContainerConfiguration(LoaderInterface $loader)
+ {
+ }
+ });
$container->registerExtension(new FrameworkExtension());
$container->registerExtension(new TwigExtension());
$container->registerExtension(new LexikCronFileGeneratorExtension());
@@ -96,8 +105,10 @@ dd($container->get('templating'));
private function compileContainer(ContainerBuilder $container)
{
$container->addCompilerPass(new TemplatingPass(), PassConfig::TYPE_BEFORE_REMOVING);
- $container->getCompilerPassConfig()->setOptimizationPasses([]);
$container->getCompilerPassConfig()->setRemovingPasses([]);
+
+ (new TwigBundle())->build($container);
+
$container->compile();
}
} |
FYI the integration of the Templating component in FrameworkBundle is deprecated in Symfony 4.3 symfony/symfony#21035 (i.e. |
Thx for you help, I have try a lot of things but not that.. 🤔 If I use use |
Nope, using the interface itself is fine, but you're relying on the |
composer.json
Outdated
@@ -13,9 +13,7 @@ | ||
"require": { | ||
"php": "^7.0", | ||
"symfony/console": "^3.4|^4.0", | ||
"symfony/framework-bundle": "^3.4|^4.0", | ||
"symfony/templating": "^3.4|^4.0", | ||
"symfony/twig-bundle": "^3.4|^4.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
framework-bundle and twig-bundle
should probably be kept (as they provide dependency-injection and http-kernel, required for a bundle)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that's was too much 🗡️
@chalasr Green is the new red! Thx for you help ;) |
No description provided.