$builder =
new ContainerBuilder();
$builder->
register('foo1', 'Bar\FooClass'
)->
setFile(__DIR__.'/Fixtures/includes/foo.php'
);
$builder->
register('foo2', 'Bar\FooClass'
)->
setFile(__DIR__.'/Fixtures/includes/%file%.php'
);
$builder->
setParameter('file', 'foo'
);
$this->
assertInstanceOf(\Bar\FooClass::
class,
$builder->
get('foo1'
), '->createService() requires the file defined by the service definition'
);
$this->
assertInstanceOf(\Bar\FooClass::
class,
$builder->
get('foo2'
), '->createService() replaces parameters in the file provided by the service definition'
);
} public function testCreateProxyWithRealServiceInstantiator() { $builder =
new ContainerBuilder();
$builder->
setProxyInstantiator(new RealServiceInstantiator());
$builder->
register('foo1', 'Bar\FooClass'
)->
setFile(__DIR__.'/Fixtures/includes/foo.php'
);
$builder->
getDefinition('foo1'
)->
setLazy(true
);
$foo1 =
$builder->
get('foo1'
);
$this->
assertSame($foo1,
$builder->
get('foo1'
), 'The same proxy is retrieved on multiple subsequent calls'
);
$this->
assertSame('Bar\FooClass',
$foo1::
class);
} public function testCreateLazyProxy() {