@@ -52,6 +52,16 @@ public function testProcess()
5252 }
5353 }
5454
55+ public function testProcessSetters ()
56+ {
57+ $ container = $ this ->getContainerWithSetter ();
58+ $ this ->assertTrue ($ container ->hasDefinition ('monolog.logger.test ' ), '->process adds a logger service for tagged service ' );
59+
60+ $ service = $ container ->getDefinition ('foo ' );
61+ $ calls = $ service ->getMethodCalls ();
62+ $ this ->assertEquals ('monolog.logger.test ' , (string ) $ calls [0 ][1 ][0 ], '->process replaces the logger by the new one in setters ' );
63+ }
64+
5565 protected function getContainer ()
5666 {
5767 $ container = new ContainerBuilder ();
@@ -92,4 +102,29 @@ protected function getContainer()
92102
93103 return $ container ;
94104 }
105+
106+ protected function getContainerWithSetter ()
107+ {
108+ $ container = new ContainerBuilder ();
109+ $ loader = new XmlFileLoader ($ container , new FileLocator (__DIR__ .'/../../../Resources/config ' ));
110+ $ loader ->load ('monolog.xml ' );
111+ $ definition = $ container ->getDefinition ('monolog.logger_prototype ' );
112+ $ container ->set ('monolog.handler.test ' , new Definition ('%monolog.handler.null.class% ' , array (100 , false )));
113+ $ definition ->addMethodCall ('pushHandler ' , array (new Reference ('monolog.handler.test ' )));
114+
115+ // Channels
116+ $ service = new Definition ('TestClass ' );
117+ $ service ->addTag ('monolog.logger ' , array ('channel ' => 'test ' ));
118+ $ service ->addMethodCall ('setLogger ' , array (new Reference ('logger ' )));
119+ $ container ->setDefinition ('foo ' , $ service );
120+
121+ $ container ->setParameter ('monolog.handlers_to_channels ' , array ());
122+
123+ $ container ->getCompilerPassConfig ()->setOptimizationPasses (array ());
124+ $ container ->getCompilerPassConfig ()->setRemovingPasses (array ());
125+ $ container ->addCompilerPass (new LoggerChannelPass ());
126+ $ container ->compile ();
127+
128+ return $ container ;
129+ }
95130}
0 commit comments