prophesize(ContainerInterface::class); /** @var ServiceManager $serviceLocatorProphecy */ $serviceLocatorProphecy = $this->prophesize(ServiceManager::class); $serviceLocatorProphecy->getContainer()->willReturn($containerProphecy); foreach ($services as $key => $service) { $serviceLocatorProphecy->get($key)->willReturn($service); $serviceLocatorProphecy->has($key)->willReturn(true); $containerProphecy->get($key)->willReturn($service); $containerProphecy->has($key)->willReturn(true); } $serviceLocatorProphecy->has(Argument::any())->willReturn(false); $containerProphecy->has(Argument::any())->willReturn(false); return $serviceLocatorProphecy->reveal(); } }