|
13 | 13 |
|
14 | 14 | use PHPUnit\Framework\TestCase;
|
15 | 15 | use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
|
| 16 | +use Symfony\Component\DependencyInjection\ChildDefinition; |
16 | 17 | use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
17 | 18 | use Symfony\Component\DependencyInjection\ContainerAwareTrait;
|
18 | 19 | use Symfony\Component\DependencyInjection\ContainerBuilder;
|
@@ -326,6 +327,29 @@ public function testDoNotBindScalarValueToControllerArgument()
|
326 | 327 | $locator = $container->getDefinition((string) $resolver->getArgument(0))->getArgument(0);
|
327 | 328 | $this->assertEmpty($locator);
|
328 | 329 | }
|
| 330 | + |
| 331 | + public function testBindingsOnChildDefinitions() |
| 332 | + { |
| 333 | + $container = new ContainerBuilder(); |
| 334 | + $resolver = $container->register('argument_resolver.service')->addArgument(array()); |
| 335 | + |
| 336 | + $container->register('parent', ArgumentWithoutTypeController::class); |
| 337 | + |
| 338 | + $container->setDefinition('child', (new ChildDefinition('parent')) |
| 339 | + ->setBindings(array('$someArg' => new Reference('parent'))) |
| 340 | + ->addTag('controller.service_arguments') |
| 341 | + ); |
| 342 | + |
| 343 | + $pass = new RegisterControllerArgumentLocatorsPass(); |
| 344 | + $pass->process($container); |
| 345 | + |
| 346 | + $locator = $container->getDefinition((string) $resolver->getArgument(0))->getArgument(0); |
| 347 | + $this->assertInstanceOf(ServiceClosureArgument::class, $locator['child:fooAction']); |
| 348 | + |
| 349 | + $locator = $container->getDefinition((string) $locator['child:fooAction']->getValues()[0])->getArgument(0); |
| 350 | + $this->assertInstanceOf(ServiceClosureArgument::class, $locator['someArg']); |
| 351 | + $this->assertEquals(new Reference('parent'), $locator['someArg']->getValues()[0]); |
| 352 | + } |
329 | 353 | }
|
330 | 354 |
|
331 | 355 | class RegisterTestController
|
|
0 commit comments