Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ServiceLocatorTestCase.php

function ServiceLocatorTestCase::testThrowsOnCircularReference

File

vendor/symfony/service-contracts/Test/ServiceLocatorTestCase.php, line 83

Class

ServiceLocatorTestCase

Namespace

Symfony\Contracts\Service\Test

Code

public function testThrowsOnCircularReference() {
    $locator = $this->getServiceLocator([
        'foo' => function () use (&$locator) {
            return $locator->get('bar');
        },
        'bar' => function () use (&$locator) {
            return $locator->get('baz');
        },
        'baz' => function () use (&$locator) {
            return $locator->get('bar');
        },
    ]);
    $this->expectException(ContainerExceptionInterface::class);
    $this->expectExceptionMessage('Circular reference detected for service "bar", path: "bar -> baz -> bar".');
    $locator->get('foo');
}
RSS feed
Powered by Drupal