$container->
register('foo', TestServiceSubscriber::
class) ->
addArgument(new Reference(PsrContainerInterface::
class)) ->
addTag('container.service_subscriber'
) ;
(new RegisterServiceSubscribersPass())->
process($container);
(new ResolveServiceSubscribersPass())->
process($container);
$foo =
$container->
getDefinition('foo'
);
$locator =
$container->
getDefinition((string) $foo->
getArgument(0
));
$this->
assertFalse($locator->
isPublic());
$this->
assertSame(ServiceLocator::
class,
$locator->
getClass());
$expected =
[ TestServiceSubscriber::
class => new ServiceClosureArgument(new TypedReference(TestServiceSubscriber::
class, TestServiceSubscriber::
class)),
CustomDefinition::
class => new ServiceClosureArgument(new TypedReference(CustomDefinition::
class, CustomDefinition::
class, ContainerInterface::IGNORE_ON_INVALID_REFERENCE
)),
'bar' =>
new ServiceClosureArgument(new TypedReference(CustomDefinition::
class, CustomDefinition::
class, ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, 'bar'
)),
'baz' =>
new ServiceClosureArgument(new TypedReference(CustomDefinition::
class, CustomDefinition::
class, ContainerInterface::IGNORE_ON_INVALID_REFERENCE, 'baz'
)),
'late_alias' =>
new ServiceClosureArgument(new TypedReference(TestDefinition1::
class, TestDefinition1::
class, ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, 'late_alias'
)),
];
$this->
assertEquals($expected,
$container->
getDefinition((string) $locator->
getFactory()[0
])->
getArgument(0
));
}