/**
  * Mark a job execution as failed
  * @param JobExecution $jobExecution
  */
 public function markAsFailed(JobExecution $jobExecution)
 {
     $jobExecution->setStatus(new BatchStatus(BatchStatus::FAILED));
     $jobExecution->setExitStatus(new ExitStatus(ExitStatus::FAILED));
     $jobExecution->setEndTime(new \DateTime('now'));
     $jobExecution->addFailureException(new \Exception('An exception occured during the job execution'));
     $this->entityManager->persist($jobExecution);
     $this->entityManager->flush();
 }
 function it_marks_a_job_execution_as_failed($entityManager, JobExecution $jobExecution)
 {
     $jobExecution->setStatus(Argument::any())->shouldBeCalled();
     $jobExecution->setExitStatus(Argument::any())->shouldBeCalled();
     $jobExecution->setEndTime(Argument::any())->shouldBeCalled();
     $jobExecution->addFailureException(Argument::any())->shouldBeCalled();
     $entityManager->persist($jobExecution)->shouldBeCalled();
     $entityManager->flush()->shouldBeCalled();
     $this->markAsFailed($jobExecution);
 }
Пример #3
0
 function it_executes(JobExecution $jobExecution, JobRepositoryInterface $jobRepository, EventDispatcherInterface $dispatcher, BatchStatus $status)
 {
     $this->setEventDispatcher($dispatcher);
     $this->setJobRepository($jobRepository);
     $jobExecution->getStatus()->willReturn($status);
     $status->getValue()->willReturn(BatchStatus::UNKNOWN);
     $dispatcher->dispatch(EventInterface::BEFORE_JOB_EXECUTION, Argument::any())->shouldBeCalled();
     $jobExecution->setStartTime(Argument::any())->shouldBeCalled();
     $jobExecution->setStatus(Argument::any())->shouldBeCalled();
     $dispatcher->dispatch(EventInterface::AFTER_JOB_EXECUTION, Argument::any())->shouldBeCalled();
     $jobExecution->setEndTime(Argument::any())->shouldBeCalled();
     $this->execute($jobExecution);
 }