コード例 #1
0
ファイル: ProcessContext.php プロジェクト: lingoda/Sylius
 /**
  * {@inheritdoc}
  */
 public function initialize(ProcessInterface $process, StepInterface $currentStep)
 {
     $this->process = $process;
     $this->currentStep = $currentStep;
     $this->storage->initialize(md5($process->getScenarioAlias()));
     $steps = $process->getOrderedSteps();
     foreach ($steps as $index => $step) {
         if ($step === $currentStep) {
             $this->previousStep = isset($steps[$index - 1]) ? $steps[$index - 1] : null;
             $this->nextStep = isset($steps[$index + 1]) ? $steps[$index + 1] : null;
             $this->calculateProgress($index);
         }
     }
     $this->initialized = true;
     return $this;
 }
コード例 #2
0
ファイル: ProcessContextSpec.php プロジェクト: nanyi/Sylius
 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();
 }