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