@@ -428,6 +428,9 @@ public function testBindWithTarget()
428
428
$ container = new ContainerBuilder ();
429
429
$ resolver = $ container ->register ('argument_resolver.service ' )->addArgument ([]);
430
430
431
+ $ container ->register (ControllerDummy::class, 'bar ' );
432
+ $ container ->register (ControllerDummy::class.' $imageStorage ' , 'baz ' );
433
+
431
434
$ container ->register ('foo ' , WithTarget::class)
432
435
->setBindings (['string $someApiKey ' => new Reference ('the_api_key ' )])
433
436
->addTag ('controller.service_arguments ' );
@@ -437,7 +440,11 @@ public function testBindWithTarget()
437
440
$ locator = $ container ->getDefinition ((string ) $ resolver ->getArgument (0 ))->getArgument (0 );
438
441
$ locator = $ container ->getDefinition ((string ) $ locator ['foo::fooAction ' ]->getValues ()[0 ]);
439
442
440
- $ expected = ['apiKey ' => new ServiceClosureArgument (new Reference ('the_api_key ' ))];
443
+ $ expected = [
444
+ 'apiKey ' => new ServiceClosureArgument (new Reference ('the_api_key ' )),
445
+ 'service1 ' => new ServiceClosureArgument (new TypedReference (ControllerDummy::class, ControllerDummy::class, ContainerInterface::RUNTIME_EXCEPTION_ON_INVALID_REFERENCE , 'imageStorage ' )),
446
+ 'service2 ' => new ServiceClosureArgument (new TypedReference (ControllerDummy::class, ControllerDummy::class, ContainerInterface::RUNTIME_EXCEPTION_ON_INVALID_REFERENCE , 'service2 ' )),
447
+ ];
441
448
$ this ->assertEquals ($ expected , $ locator ->getArgument (0 ));
442
449
}
443
450
}
@@ -513,7 +520,10 @@ class WithTarget
513
520
{
514
521
public function fooAction (
515
522
#[Target('some.api.key ' )]
516
- string $ apiKey
523
+ string $ apiKey ,
524
+ #[Target('image.storage ' )]
525
+ ControllerDummy $ service1 ,
526
+ ControllerDummy $ service2
517
527
) {
518
528
}
519
529
}
0 commit comments