/**
  * 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);
 }