You are here

public function ContainerTest::testGetCircularReference in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/dependency-injection/Tests/ContainerTest.php \Symfony\Component\DependencyInjection\Tests\ContainerTest::testGetCircularReference()

File

vendor/symfony/dependency-injection/Tests/ContainerTest.php, line 262

Class

ContainerTest

Namespace

Symfony\Component\DependencyInjection\Tests

Code

public function testGetCircularReference() {
  $sc = new ProjectServiceContainer();
  try {
    $sc
      ->get('circular');
    $this
      ->fail('->get() throws a ServiceCircularReferenceException if it contains circular reference');
  } catch (\Exception $e) {
    $this
      ->assertInstanceOf('\\Symfony\\Component\\DependencyInjection\\Exception\\ServiceCircularReferenceException', $e, '->get() throws a ServiceCircularReferenceException if it contains circular reference');
    $this
      ->assertStringStartsWith('Circular reference detected for service "circular"', $e
      ->getMessage(), '->get() throws a \\LogicException if it contains circular reference');
  }
}