|
14 | 14 | use Symfony\Bundle\MonologBundle\DependencyInjection\MonologExtension;
|
15 | 15 | use Symfony\Bundle\MonologBundle\DependencyInjection\Compiler\LoggerChannelPass;
|
16 | 16 | use Symfony\Component\DependencyInjection\ContainerBuilder;
|
| 17 | +use Symfony\Component\DependencyInjection\Definition; |
17 | 18 | use Symfony\Component\DependencyInjection\Reference;
|
18 | 19 | use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
|
19 | 20 |
|
@@ -72,6 +73,21 @@ public function testLoadWithNestedHandler()
|
72 | 73 | $this->assertDICConstructorArguments($handler, array('/tmp/symfony.log', \Monolog\Logger::ERROR, false, 0666));
|
73 | 74 | }
|
74 | 75 |
|
| 76 | + public function testLoadWithServiceHandler() |
| 77 | + { |
| 78 | + $container = $this->getContainer( |
| 79 | + array(array('handlers' => array('custom' => array('type' => 'service', 'id' => 'some.service.id')))), |
| 80 | + array('some.service.id' => new Definition('stdClass', array('foo', false))) |
| 81 | + ); |
| 82 | + |
| 83 | + $this->assertTrue($container->hasDefinition('monolog.logger')); |
| 84 | + $this->assertTrue($container->hasAlias('monolog.handler.custom')); |
| 85 | + |
| 86 | + $handler = $container->findDefinition('monolog.handler.custom'); |
| 87 | + $this->assertDICDefinitionClass($handler, 'stdClass'); |
| 88 | + $this->assertDICConstructorArguments($handler, array('foo', false)); |
| 89 | + } |
| 90 | + |
75 | 91 | /**
|
76 | 92 | * @expectedException InvalidArgumentException
|
77 | 93 | */
|
@@ -365,9 +381,13 @@ public function testFingersCrossedHandlerWhenExcluded404sAreSpecified()
|
365 | 381 | $this->assertDICConstructorArguments($handler, array(new Reference('monolog.handler.nested'), new Reference('monolog.handler.main.not_found_strategy'), 0, true, true, null));
|
366 | 382 | }
|
367 | 383 |
|
368 |
| - protected function getContainer(array $config = array()) |
| 384 | + protected function getContainer(array $config = array(), array $thirdPartyDefinitions = array()) |
369 | 385 | {
|
370 | 386 | $container = new ContainerBuilder();
|
| 387 | + foreach ($thirdPartyDefinitions as $id => $definition) { |
| 388 | + $container->setDefinition($id, $definition); |
| 389 | + } |
| 390 | + |
371 | 391 | $container->getCompilerPassConfig()->setOptimizationPasses(array());
|
372 | 392 | $container->getCompilerPassConfig()->setRemovingPasses(array());
|
373 | 393 | $container->addCompilerPass(new LoggerChannelPass());
|
|
0 commit comments