You are here

public function ContainerBuilderTest::testGetUnsetLoadingServiceWhenCreateServiceThrowsAnException in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/dependency-injection/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

vendor/symfony/dependency-injection/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');
}