コード例 #1
0
 /**
  * @param JobInterface $job
  *
  * @return bool
  */
 public function generate(JobInterface $job)
 {
     $success = $this->queueWriter->enqueue($job);
     if (!$success) {
         return false;
     }
     $jobStatus = $this->jobStatusFactory->create($job);
     $jobStatus->setWaiting();
     return true;
 }
コード例 #2
0
ファイル: JobTest.php プロジェクト: jiangyu7408/queue-worker
 /**
  *
  */
 public function test()
 {
     $processor = new JobProcessor();
     $payload = json_encode(['time' => microtime(true)]);
     $job = (new JobBuilder(new TestJob(), new Token()))->build($payload);
     $jobStatusFactory = new JobStatusFactory(new JobStatus(new JobStatusPersist()));
     $jobStatus = $jobStatusFactory->create($job);
     $processor->process($job, $jobStatus);
     $status = $jobStatus->getStatus();
     static::assertEquals(JobStatus::STATUS_COMPLETE, $status);
     $jobStatus2 = $jobStatusFactory->create($job);
     $status2 = $jobStatus2->getStatus();
     static::assertEquals(JobStatus::STATUS_COMPLETE, $status2);
     static::assertNotSame($jobStatus, $jobStatus2);
 }