public function testgetLiternal()
 {
     $config = new QueueConfig();
     $this->assertEquals('LaterJob\\Config\\QueueConfig::STATE_ADD', $config->getLiteral(1));
     $this->assertEquals('LaterJob\\Config\\QueueConfig::STATE_START', $config->getLiteral(2));
     $this->assertEquals('LaterJob\\Config\\QueueConfig::STATE_FINISH', $config->getLiteral(3));
     $this->assertEquals('LaterJob\\Config\\QueueConfig::STATE_ERROR', $config->getLiteral(4));
     $this->assertEquals('LaterJob\\Config\\QueueConfig::STATE_FAIL', $config->getLiteral(5));
 }
Example #2
0
 /**
  *  Transition a job to Finished state
  *
  *  @access public
  *  @param string $handle The worker's handle
  *  @param DateTime $start
  *  @param string $msg
  *  @throws LaterJob\Exception when starting state fails
  */
 public function finish($handle, DateTime $finish, $msg = '')
 {
     $current = $this->storage->getState();
     if ($current !== QueueConfig::STATE_START) {
         throw new LaterJobException(sprintf('Can not transiton from %s to %s', $this->getCurrentState(), $this->config->getLiteral(QueueConfig::STATE_FINISH)));
     }
     # change the state on the storage
     $this->storage->setState(QueueConfig::STATE_FINISH);
     # create the transition entity
     $trans = new Transition();
     $trans->setJob($this->getId());
     $trans->setState(QueueConfig::STATE_FINISH);
     $trans->setOccured($finish);
     $trans->setMessage(' Job ' . $this->getId() . ' FINISHED :: ' . $msg);
     $trans->setProcessHandle($handle);
     # raise the finish event
     $this->event->dispatch(JobEventsMap::STATE_FINISH, new JobTransitionEvent($this, $trans));
 }
 public function parseQueueOptions(array $options, QueueConfig $queue)
 {
     return $queue->parse($options);
 }