function ServiceLocatorTestCase::testThrowsOnCircularReference
File
-
vendor/
symfony/ service-contracts/ Test/ ServiceLocatorTestCase.php, line 83
Class
Namespace
Symfony\Contracts\Service\TestCode
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');
}