8000 minor #12024 [FrameworkBundle]Ignore LoggingTranslatorPass if there i… · symfony/symfony@11f0cb1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 11f0cb1

Browse files
committed
minor #12024 [FrameworkBundle]Ignore LoggingTranslatorPass if there is no Translator ... (aitboudad)
This PR was merged into the 2.6-dev branch. Discussion ---------- [FrameworkBundle]Ignore LoggingTranslatorPass if there is no Translator ... | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | License | MIT Commits ------- 6e1b47c [FrameworkBundle]Ignore LoggingTranslatorPass if there is no Translator definition.
2 parents cc04ce1 + 6e1b47c commit 11f0cb1

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/LoggingTranslatorPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class LoggingTranslatorPass implements CompilerPassInterface
2121
{
2222
public function process(ContainerBuilder $container)
2323
{
24-
if (!$container->hasAlias('logger')) {
24+
if (!$container->hasAlias('logger') || !$container->hasAlias('translator')) {
2525
return;
2626
}
2727

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/LoggingTranslatorPassTest.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function testProcess()
2323
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder');
2424
$parameterBag = $this->getMock('Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface');
2525

26-
$container->expects($this->once())
26+
$container->expects($this->exactly(2))
2727
->method('hasAlias')
2828
->will($this->returnValue(true));
2929

@@ -65,4 +65,19 @@ public function testThatCompilerPassIsIgnoredIfThereIsNotLoggerDefinition()
6565
$pass = new LoggingTranslatorPass();
6666
$pass->process($container);
6767
}
68+
69+
public function testThatCompilerPassIsIgnoredIfThereIsNotTranslatorDefinition()
70+
{
71+
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder');
72+
$container->expects($this->at(0))
73+
->method('hasAlias')
74+
->will($this->returnValue(true));
75+
76+
$container->expects($this->at(0))
77+
->method('hasAlias')
78+
->will($this->returnValue(false));
79+
80+
$pass = new LoggingTranslatorPass();
81+
$pass->process($container);
82+
}
6883
}

0 commit comments

Comments
 (0)
0