class ServiceLocatorTest extends ServiceLocatorTestCase
{ public function getServiceLocator(array
$factories): ContainerInterface
{ return new ServiceLocator($factories);
} public function testGetThrowsOnUndefinedService() { $this->
expectException(NotFoundExceptionInterface::
class);
$this->
expectExceptionMessage('Service "dummy" not found: the container inside "Symfony\Component\DependencyInjection\Tests\ServiceLocatorTest" is a smaller service locator that only knows about the "foo" and "bar" services.'
);
$locator =
$this->
getServiceLocator([ 'foo' =>
fn () => 'bar',
'bar' =>
fn () => 'baz',
]);
$locator->
get('dummy'
);
} public function testThrowsOnCircularReference() { $this->
expectException(ServiceCircularReferenceException::
class);
$this->
expectExceptionMessage('Circular reference detected for service "bar", path: "bar -> baz -> bar".'
);