public function ContainerBuilderTest::testLegacyCreateServiceFactory 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::testLegacyCreateServiceFactory()
File
- vendor/
symfony/ dependency-injection/ Tests/ ContainerBuilderTest.php, line 343
Class
Namespace
Symfony\Component\DependencyInjection\TestsCode
public function testLegacyCreateServiceFactory() {
$builder = new ContainerBuilder();
$builder
->register('bar', 'Bar\\FooClass');
$builder
->register('foo1', 'Bar\\FooClass')
->setFactoryClass('%foo_class%')
->setFactoryMethod('getInstance')
->addArgument(array(
'foo' => '%value%',
'%value%' => 'foo',
new Reference('bar'),
));
$builder
->setParameter('value', 'bar');
$builder
->setParameter('foo_class', 'Bar\\FooClass');
$this
->assertTrue($builder
->get('foo1')->called, '->createService() calls the factory method to create the service instance');
$this
->assertEquals(array(
'foo' => 'bar',
'bar' => 'foo',
$builder
->get('bar'),
), $builder
->get('foo1')->arguments, '->createService() passes the arguments to the factory method');
}