public function ContainerBuilderTest::testCreateServiceConfigurator in Service Container 7.2
Same name and namespace in other branches
- 7 modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php \Symfony\Component\DependencyInjection\Tests\ContainerBuilderTest::testCreateServiceConfigurator()
@covers Symfony\Component\DependencyInjection\ContainerBuilder::createService
File
- modules/
providers/ service_container_symfony/ lib/ Symfony/ Component/ DependencyInjection/ Tests/ ContainerBuilderTest.php, line 394
Class
Namespace
Symfony\Component\DependencyInjection\TestsCode
public function testCreateServiceConfigurator() {
$builder = new ContainerBuilder();
$builder
->register('foo1', 'Bar\\FooClass')
->setConfigurator('sc_configure');
$this
->assertTrue($builder
->get('foo1')->configured, '->createService() calls the configurator');
$builder
->register('foo2', 'Bar\\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', 'Bar\\FooClass')
->setConfigurator(array(
new Reference('baz'),
'configure',
));
$this
->assertTrue($builder
->get('foo3')->configured, '->createService() calls the configurator');
$builder
->register('foo4', 'Bar\\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 "Bar\\FooClass" is not a callable.', $e
->getMessage(), '->createService() throws an InvalidArgumentException if the configure callable is not a valid callable');
}
}