|
12 | 12 | namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection;
|
13 | 13 |
|
14 | 14 | use Doctrine\Common\Annotations\Annotation;
|
| 15 | +use Psr\Log\LoggerAwareInterface; |
15 | 16 | use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddAnnotationsCachedReaderPass;
|
16 | 17 | use Symfony\Bundle\FrameworkBundle\DependencyInjection\FrameworkExtension;
|
17 | 18 | use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
|
|
26 | 27 | use Symfony\Component\Cache\Adapter\RedisAdapter;
|
27 | 28 | use Symfony\Component\DependencyInjection\ChildDefinition;
|
28 | 29 | use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
| 30 | +use Symfony\Component\DependencyInjection\Compiler\ResolveInstanceofConditionalsPass; |
29 | 31 | use Symfony\Component\DependencyInjection\ContainerBuilder;
|
30 | 32 | use Symfony\Component\DependencyInjection\ContainerInterface;
|
31 | 33 | use Symfony\Component\DependencyInjection\Definition;
|
@@ -1224,6 +1226,22 @@ public function testRemovesResourceCheckerConfigCacheFactoryArgumentOnlyIfNoDebu
|
1224 | 1226 | $this->assertEmpty($container->getDefinition('config_cache_factory')->getArguments());
|
1225 | 1227 | }
|
1226 | 1228 |
|
| 1229 | + public function testLoggerAwareRegistration() |
| 1230 | + { |
| 1231 | + $container = $this->createContainerFromFile('full', array(), true, false); |
| 1232 | + $container->addCompilerPass(new ResolveInstanceofConditionalsPass()); |
| 1233 | + $container->register('foo', LoggerAwareInterface::class) |
| 1234 | + ->setAutoconfigured(true); |
| 1235 | + $container->compile(); |
| 1236 | + |
| 1237 | + $calls = $container->findDefinition('foo')->getMethodCalls(); |
| 1238 | + |
| 1239 | + $this->assertCount(1, $calls, 'Definition should contain 1 method call'); |
| 1240 | + $this->assertSame('setLogger', $calls[0][0], 'Method name should be "setLogger"'); |
| 1241 | + $this->assertInstanceOf(Reference::class, $calls[0][1][0]); |
| 1242 | + $this->assertSame('logger', (string) $calls[0][1][0], 'Argument should be a reference to "logger"'); |
| 1243 | + } |
| 1244 | + |
1227 | 1245 | protected function createContainer(array $data = array())
|
1228 | 1246 | {
|
1229 | 1247 | return new ContainerBuilder(new ParameterBag(array_merge(array(
|
|
0 commit comments