public function ContainerTest::testGetThrowsExceptionOnServiceConfiguration

File

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

Class

ContainerTest

Namespace

Symfony\Component\DependencyInjection\Tests

Code

public function testGetThrowsExceptionOnServiceConfiguration() {
  $c = new ProjectServiceContainer();
  try {
    $c
      ->get('throws_exception_on_service_configuration');
    $this
      ->fail('The container can not contain invalid service!');
  } catch (\Exception $e) {
    $this
      ->assertEquals('Something was terribly wrong while trying to configure the service!', $e
      ->getMessage());
  }
  $this
    ->assertFalse($c
    ->initialized('throws_exception_on_service_configuration'));
  try {
    $c
      ->get('throws_exception_on_service_configuration');
    $this
      ->fail('The container can not contain invalid service!');
  } catch (\Exception $e) {
    $this
      ->assertEquals('Something was terribly wrong while trying to configure the service!', $e
      ->getMessage());
  }
  $this
    ->assertFalse($c
    ->initialized('throws_exception_on_service_configuration'));
}