/**
  * @test
  */
 public function waitAndExecuteGetsAndExecutesJobFromQueue()
 {
     $job = new TestJob();
     $this->jobManager->queue('TestQueue', $job);
     /** @var TestJob $queuedJob */
     $queuedJob = $this->jobManager->waitAndExecute('TestQueue');
     $this->assertTrue($queuedJob->getProcessed());
 }
 /**
  * Work on a queue and execute jobs
  *
  * @param string $queueName The name of the queue
  * @param integer $limit The max number of jobs that should execute before exiting.
  * @return void
  */
 public function workCommand($queueName, $limit = 0)
 {
     $runInfiniteJobs = $limit === 0 || $limit < 0;
     $jobsDone = 0;
     do {
         try {
             $jobsDone++;
             $this->jobManager->waitAndExecute($queueName);
         } catch (JobQueueException $exception) {
             $this->outputLine($exception->getMessage());
             if ($exception->getPrevious() instanceof \Exception) {
                 $this->outputLine($exception->getPrevious()->getMessage());
             }
         } catch (\Exception $exception) {
             $this->outputLine('Unexpected exception during job execution: %s', array($exception->getMessage()));
         }
     } while ($runInfiniteJobs || $jobsDone < $limit);
 }
 /**
  * Work on a queue and execute jobs
  *
  * @param string $queueName The name of the queue
  * @return void
  */
 public function workCommand($queueName)
 {
     do {
         $this->jobManager->waitAndExecute($queueName);
     } while (TRUE);
 }