/** * {@inheritdoc} */ public function isolateEnvironment(Environment $uninitializedEnvironment, $testSubject = null) { if (!$uninitializedEnvironment instanceof UninitializedContextServiceEnvironment) { throw new EnvironmentIsolationException(sprintf('ContextServiceEnvironmentHandler does not support isolation of `%s` environment.', get_class($uninitializedEnvironment)), $uninitializedEnvironment); } if (!$this->container->isScopeActive('scenario')) { $this->container->enterScope('scenario'); } $environment = new InitializedContextEnvironment($uninitializedEnvironment->getSuite()); foreach ($uninitializedEnvironment->getContextsServicesIds() as $serviceId) { /** @var Context $context */ $context = $this->container->get($serviceId); $environment->registerContext($context); } return $environment; }
/** * {@inheritdoc} */ public function isolateEnvironment(Environment $uninitializedEnvironment, $testSubject = null) { if (!$uninitializedEnvironment instanceof UninitializedContextEnvironment) { throw new EnvironmentIsolationException(sprintf('ContextEnvironmentHandler does not support isolation of `%s` environment.', get_class($uninitializedEnvironment)), $uninitializedEnvironment); } $environment = new InitializedContextEnvironment($uninitializedEnvironment->getSuite()); foreach ($uninitializedEnvironment->getContextClassesWithArguments() as $class => $arguments) { $context = $this->factory->createContext($class, $arguments); $environment->registerContext($context); } return $environment; }