/**
  * @test
  */
 public function countReturnsNumberOfReadyJobs()
 {
     $this->queue->submit('First message');
     $this->queue->submit('Second message');
     $this->assertSame(2, $this->queue->count());
 }
Example #2
0
 /**
  * @param QueueInterface $queue
  * @param Message $message
  * @return void
  * @throws JobQueueException
  * @internal This method has to be public so that it can be run from the command handler (when "executeIsolated" is set). It is not meant to be called from "user land"
  */
 public function executeJobForMessage(QueueInterface $queue, Message $message)
 {
     // TODO stabilize unserialize() call (maybe using PHPs unserialize_callback_func directive)
     $job = unserialize($message->getPayload());
     if (!$job instanceof JobInterface) {
         throw new \RuntimeException(sprintf('The message "%s" in queue "%s" could not be unserialized to a class implementing JobInterface', $message->getIdentifier(), $queue->getName()), 1465901245);
     }
     $jobExecutionSuccess = $job->execute($queue, $message);
     if (!$jobExecutionSuccess) {
         throw new JobQueueException(sprintf('execute() for job "%s" did not return TRUE', $job->getLabel()), 1468927872);
     }
 }