|
11 | 11 |
|
12 | 12 | namespace Symfony\Component\DependencyInjection\Tests\Compiler;
|
13 | 13 |
|
| 14 | +use Symfony\Component\DependencyInjection\Alias; |
| 15 | +use Symfony\Component\DependencyInjection\Definition; |
14 | 16 | use Symfony\Component\DependencyInjection\Reference;
|
15 | 17 | use Symfony\Component\DependencyInjection\Compiler\ResolveReferencesToAliasesPass;
|
16 | 18 | use Symfony\Component\DependencyInjection\ContainerBuilder;
|
@@ -59,6 +61,27 @@ public function testAliasCircularReference()
|
59 | 61 | $this->process($container);
|
60 | 62 | }
|
61 | 63 |
|
| 64 | + public function testResolveFactory() |
| 65 | + { |
| 66 | + $container = new ContainerBuilder(); |
| 67 | + $container->register('factory', 'Factory'); |
| 68 | + $container->setAlias('factory_alias', new Alias('factory')); |
| 69 | + $foo = new Definition(); |
| 70 | + $foo->setFactory(array(new Reference('factory_alias'), 'createFoo')); |
| 71 | + $container->setDefinition('foo', $foo); |
| 72 | + $bar = new Definition(); |
| 73 | + $bar->setFactory(array('Factory', 'createFoo')); |
| 74 | + $container->setDefinition('bar', $bar); |
| 75 | + |
| 76 | + $this->process($container); |
| 77 | + |
| 78 | + $resolvedFooFactory = $container->getDefinition('foo')->getFactory(); |
| 79 | + $resolvedBarFactory = $container->getDefinition('bar')->getFactory(); |
| 80 | + |
| 81 | + $this->assertSame('factory', (string) $resolvedFooFactory[0]); |
| 82 | + $this->assertSame('Factory', (string) $resolvedBarFactory[0]); |
| 83 | + } |
| 84 | + |
62 | 85 | protected function process(ContainerBuilder $container)
|
63 | 86 | {
|
64 | 87 | $pass = new ResolveReferencesToAliasesPass();
|
|
0 commit comments