function it_should_add_active_steps(StepInterface $step, ProcessScenarioInterface $scenario) { $step->getName()->willReturn(null); $this->build($scenario); $step->isActive()->willReturn(true); $step->setName('foobar')->shouldBeCalled(); $this->add('foobar', $step); }
function its_step_is_mutable(StepInterface $step, StepInterface $secondStep) { $step->getName()->shouldBeCalled()->willReturn('name'); $secondStep->getName()->shouldBeCalled()->willReturn('other_name'); $this->setSteps(array('name' => $step)); $this->addStep('other_name', $secondStep); $this->removeStep('name'); $this->getSteps()->shouldReturn(array('other_name' => $secondStep)); $this->getOrderedSteps()->shouldReturn(array($secondStep)); }
/** * {@inheritdoc} */ public function rewindHistory() { $history = $this->getStepHistory(); while ($top = end($history)) { if ($top !== $this->currentStep->getName()) { array_pop($history); } else { break; } } if (0 === count($history)) { throw new NotFoundHttpException(sprintf('Step "%s" not found in step history.', $this->currentStep->getName())); } $this->setStepHistory($history); }
/** * Redirect to step display action. * * @param ProcessInterface $process * @param StepInterface $step * @param ParameterBag $queryParameters * * @return RedirectResponse */ protected function redirectToStepDisplayAction(ProcessInterface $process, StepInterface $step, ParameterBag $queryParameters = null) { $this->context->addStepToHistory($step->getName()); if (null !== ($route = $process->getDisplayRoute())) { $url = $this->router->generate($route, array_merge($process->getDisplayRouteParams(), array('stepName' => $step->getName()), $queryParameters ? $queryParameters->all() : array())); return new RedirectResponse($url); } // Default parameters for display route $routeParameters = array('scenarioAlias' => $process->getScenarioAlias(), 'stepName' => $step->getName()); if (null !== $queryParameters) { $routeParameters = array_merge($queryParameters->all(), $routeParameters); } return new RedirectResponse($this->router->generate('sylius_flow_display', $routeParameters)); }
/** * {@inheritdoc} */ public function addStep($name, StepInterface $step) { if ($this->hasStep($name)) { throw new \InvalidArgumentException(sprintf('Step with name "%s" already exists', $name)); } if (null === $step->getName()) { $step->setName($name); } $this->steps[$name] = $this->orderedSteps[] = $step; }
function it_rewind_history($storage, ProcessInterface $process, StepInterface $currentStep, StepInterface $previousStep, StepInterface $nextStep) { $currentStep->getName()->willReturn('step_two'); $process->getScenarioAlias()->shouldBeCalled(); $storage->initialize(Argument::type('string'))->shouldBeCalled(); $process->getOrderedSteps()->shouldBeCalled()->willReturn(array($previousStep, $currentStep, $nextStep)); $process->countSteps()->shouldBeCalled()->willReturn(2); $this->initialize($process, $currentStep); $storage->get("history", array())->shouldBeCalled()->willreturn(array("step_one", "step_two", "step_three")); $storage->set('history', array('step_one', 'step_two'))->shouldBeCalled(); $this->rewindHistory(); }