public function ContainerBuilderTest::testLegacyCreateServiceFactory in Service Container 7
Same name and namespace in other branches
- 7.2 modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php \Symfony\Component\DependencyInjection\Tests\ContainerBuilderTest::testLegacyCreateServiceFactory()
File
- modules/
providers/ service_container_symfony/ lib/ Symfony/ Component/ DependencyInjection/ Tests/ ContainerBuilderTest.php, line 343
Class
Namespace
Symfony\Component\DependencyInjection\TestsCode
public function testLegacyCreateServiceFactory() {
$this
->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$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');
}