[FrameworkBundle]Ignore LoggingTranslatorPass if there is no Translator definition.
This commit is contained in:
parent
cc04ce15c0
commit
6e1b47c3fd
@ -21,7 +21,7 @@ class LoggingTranslatorPass implements CompilerPassInterface
|
|||||||
{
|
{
|
||||||
public function process(ContainerBuilder $container)
|
public function process(ContainerBuilder $container)
|
||||||
{
|
{
|
||||||
if (!$container->hasAlias('logger')) {
|
if (!$container->hasAlias('logger') || !$container->hasAlias('translator')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ class LoggingTranslatorPassTest extends \PHPUnit_Framework_TestCase
|
|||||||
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder');
|
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder');
|
||||||
$parameterBag = $this->getMock('Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface');
|
$parameterBag = $this->getMock('Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface');
|
||||||
|
|
||||||
$container->expects($this->once())
|
$container->expects($this->exactly(2))
|
||||||
->method('hasAlias')
|
->method('hasAlias')
|
||||||
->will($this->returnValue(true));
|
->will($this->returnValue(true));
|
||||||
|
|
||||||
@ -65,4 +65,19 @@ class LoggingTranslatorPassTest extends \PHPUnit_Framework_TestCase
|
|||||||
$pass = new LoggingTranslatorPass();
|
$pass = new LoggingTranslatorPass();
|
||||||
$pass->process($container);
|
$pass->process($container);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testThatCompilerPassIsIgnoredIfThereIsNotTranslatorDefinition()
|
||||||
|
{
|
||||||
|
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder');
|
||||||
|
$container->expects($this->at(0))
|
||||||
|
->method('hasAlias')
|
||||||
|
->will($this->returnValue(true));
|
||||||
|
|
||||||
|
$container->expects($this->at(0))
|
||||||
|
->method('hasAlias')
|
||||||
|
->will($this->returnValue(false));
|
||||||
|
|
||||||
|
$pass = new LoggingTranslatorPass();
|
||||||
|
$pass->process($container);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user