->
setPublic(true
);
$builder->
compile();
$builder->
get('foo'
);
} public function testResolveServices() { $builder =
new ContainerBuilder();
$builder->
register('foo', 'Bar\FooClass'
);
$this->
assertEquals($builder->
get('foo'
),
$builder->
resolveServices(new Reference('foo'
)), '->resolveServices() resolves service references to service instances'
);
$this->
assertEquals(['foo' =>
['foo',
$builder->
get('foo'
)]],
$builder->
resolveServices(['foo' =>
['foo',
new Reference('foo'
)]]), '->resolveServices() resolves service references to service instances in nested arrays'
);
$this->
assertEquals($builder->
get('foo'
),
$builder->
resolveServices(new Expression('service("foo")'
)), '->resolveServices() resolves expressions'
);
} public function testResolveServicesWithDecoratedDefinition() { $this->
expectException(RuntimeException::
class);
$this->
expectExceptionMessage('Constructing service "foo" from a parent definition is not supported at build time.'
);
$builder =
new ContainerBuilder();
$builder->
setDefinition('grandpa',
new Definition('stdClass'
));
$builder->
setDefinition('parent',
new ChildDefinition('grandpa'
));