|
13 | 13 |
|
14 | 14 | use PHPUnit\Framework\TestCase;
|
15 | 15 | use Psr\Log\LoggerInterface;
|
16 |
| -use Symfony\Component\DependencyInjection\Reference; |
17 |
| -use Symfony\Component\DependencyInjection\Definition; |
18 |
| -use Symfony\Component\DependencyInjection\ContainerBuilder; |
19 | 16 | use Symfony\Bundle\MonologBundle\DependencyInjection\Compiler\LoggerChannelPass;
|
20 | 17 | use Symfony\Component\Config\FileLocator;
|
| 18 | +use Symfony\Component\DependencyInjection\ContainerBuilder; |
| 19 | +use Symfony\Component\DependencyInjection\Definition; |
21 | 20 | use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
|
| 21 | +use Symfony\Component\DependencyInjection\Reference; |
22 | 22 |
|
23 | 23 | class LoggerChannelPassTest extends TestCase
|
24 | 24 | {
|
@@ -51,7 +51,19 @@ public function testProcess()
|
51 | 51 | }
|
52 | 52 | }
|
53 | 53 |
|
54 |
| - $this->assertNotNull($container->getDefinition('monolog.logger.manualchan')); |
| 54 | + $this->assertNotNull($container->getDefinition('monolog.logger.additional')); |
| 55 | + |
| 56 | + if (!\method_exists(ContainerBuilder::class, 'registerAliasForArgument')) { |
| 57 | + return; |
| 58 | + } |
| 59 | + |
| 60 | + $expectedChannels = \array_keys($expected); |
| 61 | + $expectedChannels[] = 'additional'; |
| 62 | + |
| 63 | + foreach ($expectedChannels as $channelName) { |
| 64 | + $aliasName = LoggerInterface::class.' $monologLogger'.\ucfirst($channelName); |
| 65 | + $this->assertTrue($container->hasAlias($aliasName), 'type-hinted alias should be exists for each logger channel'); |
| 66 | + } |
55 | 67 | }
|
56 | 68 |
|
57 | 69 | public function testProcessSetters()
|
@@ -166,7 +178,7 @@ private function getContainer()
|
166 | 178 | $container->setDefinition($name, $service);
|
167 | 179 | }
|
168 | 180 |
|
169 |
| - $container->setParameter('monolog.additional_channels', array('manualchan')); |
| 181 | + $container->setParameter('monolog.additional_channels', array('additional')); |
170 | 182 | $container->setParameter('monolog.handlers_to_channels', array(
|
171 | 183 | 'monolog.handler.a' => array(
|
172 | 184 | 'type' => 'inclusive',
|
@@ -202,7 +214,7 @@ private function getContainerWithSetter()
|
202 | 214 | $service->addMethodCall('setLogger', array(new Reference('logger')));
|
203 | 215 | $container->setDefinition('foo', $service);
|
204 | 216 |
|
205 |
| - $container->setParameter('monolog.additional_channels', array('manualchan')); |
| 217 | + $container->setParameter('monolog.additional_channels', array('additional')); |
206 | 218 | $container->setParameter('monolog.handlers_to_channels', array());
|
207 | 219 |
|
208 | 220 | $container->getCompilerPassConfig()->setOptimizationPasses(array());
|
|
0 commit comments