@covers Symfony\Component\DependencyInjection\ContainerBuilder::createService
public function testCreateServiceConfigurator() {
$builder = new ContainerBuilder();
$builder
->register('foo1', 'FooClass')
->setConfigurator('sc_configure');
$this
->assertTrue($builder
->get('foo1')->configured, '->createService() calls the configurator');
$builder
->register('foo2', 'FooClass')
->setConfigurator(array(
'%class%',
'configureStatic',
));
$builder
->setParameter('class', 'BazClass');
$this
->assertTrue($builder
->get('foo2')->configured, '->createService() calls the configurator');
$builder
->register('baz', 'BazClass');
$builder
->register('foo3', 'FooClass')
->setConfigurator(array(
new Reference('baz'),
'configure',
));
$this
->assertTrue($builder
->get('foo3')->configured, '->createService() calls the configurator');
$builder
->register('foo4', 'FooClass')
->setConfigurator('foo');
try {
$builder
->get('foo4');
$this
->fail('->createService() throws an InvalidArgumentException if the configure callable is not a valid callable');
} catch (\InvalidArgumentException $e) {
$this
->assertEquals('The configure callable for class "FooClass" is not a callable.', $e
->getMessage(), '->createService() throws an InvalidArgumentException if the configure callable is not a valid callable');
}
}