You are here

public function ContainerBuilderTest::testGetUnsetLoadingServiceWhenCreateServiceThrowsAnException 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::testGetUnsetLoadingServiceWhenCreateServiceThrowsAnException()

@covers \Symfony\Component\DependencyInjection\ContainerBuilder::get @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException @expectedExceptionMessage You have requested a synthetic service ("foo"). The DIC does not know how to construct this service.

File

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

Class

ContainerBuilderTest

Namespace

Symfony\Component\DependencyInjection\Tests

Code

public function testGetUnsetLoadingServiceWhenCreateServiceThrowsAnException() {
  $builder = new ContainerBuilder();
  $builder
    ->register('foo', 'stdClass')
    ->setSynthetic(true);

  // we expect a RuntimeException here as foo is synthetic
  try {
    $builder
      ->get('foo');
  } catch (RuntimeException $e) {
  }

  // we must also have the same RuntimeException here
  $builder
    ->get('foo');
}