Skip to content

Commit 8da880c

Browse files
committed
Fixed notice in AddCacheWarmerPass if there is no cache warmer defined.
1 parent 8c6c86c commit 8da880c

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ public function process(ContainerBuilder $container)
3737
$warmers[$priority][] = new Reference($id);
3838
}
3939

40+
if (empty($warmers)) {
41+
return;
42+
}
43+
4044
// sort by priority and flatten
4145
krsort($warmers);
4246
$warmers = call_user_func_array('array_merge', $warmers);

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,24 @@ public function testThatCompilerPassIsIgnoredIfThereIsNoCacheWarmerDefinition()
6969
$addCacheWarmerPass = new AddCacheWarmerPass();
7070
$addCacheWarmerPass->process($container);
7171
}
72+
73+
public function testThatCacheWarmersMightBeNotDefined()
74+
{
75+
$definition = $this->getMock('Symfony\Component\DependencyInjection\Definition');
76+
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder');
77+
78+
$container->expects($this->atLeastOnce())
79+
->method('findTaggedServiceIds')
80+
->will($this->returnValue(array()));
81+
$container->expects($this->never())->method('getDefinition');
82+
$container->expects($this->atLeastOnce())
83+
->method('hasDefinition')
84+
->with('cache_warmer')
85+
->will($this->returnValue(true));
86+
87+
$definition->expects($this->never())->method('replaceArgument');
88+
89+
$addCacheWarmerPass = new AddCacheWarmerPass();
90+
$addCacheWarmerPass->process($container);
91+
}
7292
}

0 commit comments

Comments
 (0)