Symfony 4将在测试环境中添加test.service_container
服务。
vendor / symfony / framework-bundle / DependencyInjection / FrameworkExtension.php
if (!empty($config['test'])) {
$loader->load('test.xml');
}
但是当我尝试在自定义包中替换其类时
final class AppCoreExtension extends Extension
{
/**
* {@inheritdoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
if ($container->getParameter('kernel.environment') !== 'prod') {
$container
->getDefinition('test.service_container')
->setClass(MockerTestContainer::class);
}
}
}
出现此错误
您请求的服务“ test.service_container”不存在