public function ContainerBuilderTest::testCreateService

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

File

drupal/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php, line 257

Class

ContainerBuilderTest

Namespace

Symfony\Component\DependencyInjection\Tests

Code

public function testCreateService() {
  $builder = new ContainerBuilder();
  $builder
    ->register('foo1', 'FooClass')
    ->setFile(__DIR__ . '/Fixtures/includes/foo.php');
  $this
    ->assertInstanceOf('\\FooClass', $builder
    ->get('foo1'), '->createService() requires the file defined by the service definition');
  $builder
    ->register('foo2', 'FooClass')
    ->setFile(__DIR__ . '/Fixtures/includes/%file%.php');
  $builder
    ->setParameter('file', 'foo');
  $this
    ->assertInstanceOf('\\FooClass', $builder
    ->get('foo2'), '->createService() replaces parameters in the file provided by the service definition');
}