1212namespace Symfony \Bundle \MonologBundle \Tests \DependencyInjection ;
1313
1414use Symfony \Bundle \MonologBundle \DependencyInjection \MonologExtension ;
15+ use Symfony \Bundle \MonologBundle \DependencyInjection \Compiler \LoggerChannelPass ;
1516use Symfony \Component \DependencyInjection \ContainerBuilder ;
1617use Symfony \Component \DependencyInjection \Reference ;
1718
@@ -27,6 +28,7 @@ public function testLoadWithSeveralHandlers()
2728 $ this ->assertTrue ($ container ->hasDefinition ('monolog.handler.nested ' ));
2829
2930 $ logger = $ container ->getDefinition ('monolog.logger ' );
31+ $ this ->assertCount (2 , $ logger ->getMethodCalls ());
3032 $ this ->assertDICDefinitionMethodCallAt (1 , $ logger , 'pushHandler ' , array (new Reference ('monolog.handler.custom ' )));
3133 $ this ->assertDICDefinitionMethodCallAt (0 , $ logger , 'pushHandler ' , array (new Reference ('monolog.handler.main ' )));
3234
@@ -49,6 +51,7 @@ public function testLoadWithOverwriting()
4951 $ this ->assertTrue ($ container ->hasDefinition ('monolog.handler.nested ' ));
5052
5153 $ logger = $ container ->getDefinition ('monolog.logger ' );
54+ $ this ->assertCount (2 , $ logger ->getMethodCalls ());
5255 $ this ->assertDICDefinitionMethodCallAt (1 , $ logger , 'pushHandler ' , array (new Reference ('monolog.handler.custom ' )));
5356 $ this ->assertDICDefinitionMethodCallAt (0 , $ logger , 'pushHandler ' , array (new Reference ('monolog.handler.main ' )));
5457
@@ -72,9 +75,10 @@ public function testLoadWithNewAtEnd()
7275 $ this ->assertTrue ($ container ->hasDefinition ('monolog.handler.new ' ));
7376
7477 $ logger = $ container ->getDefinition ('monolog.logger ' );
75- $ this ->assertDICDefinitionMethodCallAt (2 , $ logger , 'pushHandler ' , array (new Reference ('monolog.handler.new ' )));
76- $ this ->assertDICDefinitionMethodCallAt (1 , $ logger , 'pushHandler ' , array (new Reference ('monolog.handler.custom ' )));
77- $ this ->assertDICDefinitionMethodCallAt (0 , $ logger , 'pushHandler ' , array (new Reference ('monolog.handler.main ' )));
78+ $ this ->assertCount (3 , $ logger ->getMethodCalls ());
79+ $ this ->assertDICDefinitionMethodCallAt (2 , $ logger , 'pushHandler ' , array (new Reference ('monolog.handler.custom ' )));
80+ $ this ->assertDICDefinitionMethodCallAt (1 , $ logger , 'pushHandler ' , array (new Reference ('monolog.handler.main ' )));
81+ $ this ->assertDICDefinitionMethodCallAt (0 , $ logger , 'pushHandler ' , array (new Reference ('monolog.handler.new ' )));
7882
7983 $ handler = $ container ->getDefinition ('monolog.handler.new ' );
8084 $ this ->assertDICDefinitionClass ($ handler , '%monolog.handler.stream.class% ' );
@@ -93,10 +97,11 @@ public function testLoadWithNewAndPriority()
9397 $ this ->assertTrue ($ container ->hasDefinition ('monolog.handler.last ' ));
9498
9599 $ logger = $ container ->getDefinition ('monolog.logger ' );
96- $ this ->assertDICDefinitionMethodCallAt (2 , $ logger , 'pushHandler ' , array (new Reference ('monolog.handler.last ' )));
97- $ this ->assertDICDefinitionMethodCallAt (1 , $ logger , 'pushHandler ' , array (new Reference ('monolog.handler.custom ' )));
98- $ this ->assertDICDefinitionMethodCallAt (0 , $ logger , 'pushHandler ' , array (new Reference ('monolog.handler.main ' )));
99- $ this ->assertDICDefinitionMethodCallAt (2 , $ logger , 'pushHandler ' , array (new Reference ('monolog.handler.first ' )));
100+ $ this ->assertCount (4 , $ logger ->getMethodCalls ());
101+ $ this ->assertDICDefinitionMethodCallAt (3 , $ logger , 'pushHandler ' , array (new Reference ('monolog.handler.first ' )));
102+ $ this ->assertDICDefinitionMethodCallAt (2 , $ logger , 'pushHandler ' , array (new Reference ('monolog.handler.custom ' )));
103+ $ this ->assertDICDefinitionMethodCallAt (1 , $ logger , 'pushHandler ' , array (new Reference ('monolog.handler.main ' )));
104+ $ this ->assertDICDefinitionMethodCallAt (0 , $ logger , 'pushHandler ' , array (new Reference ('monolog.handler.last ' )));
100105
101106 $ handler = $ container ->getDefinition ('monolog.handler.main ' );
102107 $ this ->assertDICDefinitionClass ($ handler , '%monolog.handler.buffer.class% ' );
@@ -135,6 +140,7 @@ protected function getContainer($fixture)
135140
136141 $ container ->getCompilerPassConfig ()->setOptimizationPasses (array ());
137142 $ container ->getCompilerPassConfig ()->setRemovingPasses (array ());
143+ $ container ->addCompilerPass (new LoggerChannelPass ());
138144 $ container ->compile ();
139145
140146 return $ container ;
0 commit comments