'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".'
);
parent::
testThrowsOnCircularReference();
} public function testThrowsInServiceSubscriber() { $this->
expectException(NotFoundExceptionInterface::
class);
$this->
expectExceptionMessage('Service "foo" not found: even though it exists in the app\'s container, the container inside "caller" is a smaller service locator that only knows about the "bar" service. Unless you need extra laziness, try using dependency injection instead. Otherwise, you need to declare it using "SomeServiceSubscriber::getSubscribedServices()".'
);
$container =
new Container();
$container->
set('foo',
new \
stdClass());
$subscriber =
new SomeServiceSubscriber();
$subscriber->container =
$this->
getServiceLocator(['bar' =>
function D
) {}]);
$subscriber->container =
$subscriber->container->
withContext('caller',
$container);