Exemple #1
0
 /**
  * {@inheritdoc}
  */
 public function setStatus(Status $status)
 {
     $this->status = $status->getValue();
     $this->enumStatus = $status;
 }
Exemple #2
0
 /**
  * @param Status $status
  * @return bool Whether the given status indicates that the job is terminated
  */
 public static function isTerminated(Status $status)
 {
     return in_array($status->getValue(), static::$terminated_status_values);
 }
 /**
  * @param Status $status
  * @dataProvider provideUnterminatedStatus
  */
 public function testCancel(Status $status)
 {
     $isProcessing = $status->getValue() == Status::PROCESSING;
     $job = new Job();
     $job->setTicket('ticket');
     $job->setStatus($status);
     $terminationEvent = new TerminationEvent($job);
     $this->jobManager->expects($this->once())->method('findByTicket')->with($job->getTicket())->willReturn($job);
     $this->helper->expects($this->once())->method('updateJob')->with($job, $isProcessing ? Status::CANCELLING() : Status::CANCELLED())->willReturnCallback(function (JobInterface $job, Status $status) {
         $job->setStatus($status);
     });
     $this->jobManager->expects($this->once())->method('save')->with($this->callback(function ($arg) use($job, $isProcessing) {
         return $arg === $job && $arg->getStatus() == ($isProcessing ? Status::CANCELLING() : Status::CANCELLED());
     }));
     $this->dispatcher->expects($isProcessing ? $this->never() : $this->once())->method('dispatch')->with(JobEvents::JOB_TERMINATED, $terminationEvent);
     $this->subject->cancel($job->getTicket());
 }