|
15 | 15 | use Symfony\Component\DependencyInjection\Argument\BoundArgument;
|
16 | 16 | use Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument;
|
17 | 17 | use Symfony\Component\DependencyInjection\Compiler\AutowireRequiredMethodsPass;
|
| 18 | +use Symfony\Component\DependencyInjection\Compiler\DefinitionErrorExceptionPass; |
18 | 19 | use Symfony\Component\DependencyInjection\Compiler\ResolveBindingsPass;
|
19 | 20 | use Symfony\Component\DependencyInjection\ContainerBuilder;
|
20 | 21 | use Symfony\Component\DependencyInjection\Definition;
|
| 22 | +use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; |
21 | 23 | use Symfony\Component\DependencyInjection\Reference;
|
22 | 24 | use Symfony\Component\DependencyInjection\Tests\Fixtures\CaseSensitiveClass;
|
23 | 25 | use Symfony\Component\DependencyInjection\Tests\Fixtures\NamedArgumentsDummy;
|
@@ -131,4 +133,25 @@ public function testWithNonExistingSetterAndBinding()
|
131 | 133 | $pass = new ResolveBindingsPass();
|
132 | 134 | $pass->process($container);
|
133 | 135 | }
|
| 136 | + |
| 137 | + public function testSyntheticServiceWithBind() |
| 138 | + { |
| 139 | + $container = new ContainerBuilder(); |
| 140 | + $argument = new BoundArgument('bar'); |
| 141 | + |
| 142 | + $container->register('foo', 'stdClass') |
| 143 | + ->addArgument(new Reference('synthetic.service')); |
| 144 | + |
| 145 | + $container->register('synthetic.service') |
| 146 | + ->setSynthetic(true) |
| 147 | + ->setBindings(['$apiKey' => $argument]); |
| 148 | + |
| 149 | + $container->register(NamedArgumentsDummy::class, NamedArgumentsDummy::class) |
| 150 | + ->setBindings(['$apiKey' => $argument]); |
| 151 | + |
| 152 | + (new ResolveBindingsPass())->process($container); |
| 153 | + (new DefinitionErrorExceptionPass())->process($container); |
| 154 | + |
| 155 | + $this->assertSame([1 => 'bar'], $container->getDefinition(NamedArgumentsDummy::class)->getArguments()); |
| 156 | + } |
134 | 157 | }
|
0 commit comments