You are here

public function ContainerBuilderTest::testLegacyCreateServiceFactoryService in Service Container 7.2

Same name and namespace in other branches
  1. 7 modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php \Symfony\Component\DependencyInjection\Tests\ContainerBuilderTest::testLegacyCreateServiceFactoryService()

@covers Symfony\Component\DependencyInjection\ContainerBuilder::createService

File

modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php, line 364

Class

ContainerBuilderTest

Namespace

Symfony\Component\DependencyInjection\Tests

Code

public function testLegacyCreateServiceFactoryService() {
  $this
    ->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
  $builder = new ContainerBuilder();
  $builder
    ->register('foo_service', 'Bar\\FooClass');
  $builder
    ->register('foo', 'Bar\\FooClass')
    ->setFactoryService('%foo_service%')
    ->setFactoryMethod('getInstance');
  $builder
    ->setParameter('foo_service', 'foo_service');
  $this
    ->assertTrue($builder
    ->get('foo')->called, '->createService() calls the factory method to create the service instance');
}