public function ContainerBuilderTest::testCreateServiceConfigurator in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/dependency-injection/Tests/ContainerBuilderTest.php \Symfony\Component\DependencyInjection\Tests\ContainerBuilderTest::testCreateServiceConfigurator()
@covers Symfony\Component\DependencyInjection\ContainerBuilder::createService
File
- vendor/
symfony/ dependency-injection/ Tests/ ContainerBuilderTest.php, line 390
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(array(
$builder
->getDefinition('baz'),
'configure',
));
$this
->assertTrue($builder
->get('foo4')->configured, '->createService() calls the configurator');
$builder
->register('foo5', 'Bar\\FooClass')
->setConfigurator('foo');
try {
$builder
->get('foo5');
$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');
}
}