function it_gets_step_names(StepInterface $stepOne, StepInterface $stepTwo) { $this->setSteps([$stepOne, $stepTwo]); $stepOne->getName()->willReturn('one'); $stepTwo->getName()->willReturn('two'); $this->getStepNames()->shouldReturn(['one', 'two']); }
/** * Handle a step and return the execution for it. * @param StepInterface $step Step * @param JobExecution $jobExecution Job execution * * @throws JobInterruptedException * * @return StepExecution */ protected function handleStep(StepInterface $step, JobExecution $jobExecution) { if ($jobExecution->isStopping()) { throw new JobInterruptedException("JobExecution interrupted."); } $stepExecution = $jobExecution->createStepExecution($step->getName()); try { $step->setJobRepository($this->jobRepository); $step->execute($stepExecution); } catch (JobInterruptedException $e) { $stepExecution->setStatus(new BatchStatus(BatchStatus::STOPPING)); $this->jobRepository->updateStepExecution($stepExecution); throw $e; } if ($stepExecution->getStatus()->getValue() == BatchStatus::STOPPING || $stepExecution->getStatus()->getValue() == BatchStatus::STOPPED) { $jobExecution->setStatus(new BatchStatus(BatchStatus::STOPPING)); $this->jobRepository->updateJobExecution($jobExecution); throw new JobInterruptedException("Job interrupted by step execution"); } return $stepExecution; }