예제 #1
0
 public function testDeleteJobFromQueue()
 {
     $pheanstalk = $this->createPheanstalkMock();
     $pheanstalk->method('delete')->willReturn($pheanstalk);
     $job = new Job($this->job_name, $this->job_data);
     $job->setId(123456);
     $queue = new BeanstalkQueue($pheanstalk, 'test');
     $queue->delete($job);
 }
예제 #2
0
 /**
  * @param Job $job
  */
 protected function executeJob($job)
 {
     $this->log('Executing job ' . $job->getId());
     if ($this->runner->runJob($job)) {
         $this->queue->delete($job);
     } else {
         $this->log("Job failed");
         if ($this->queue->countReserves($job) < 3) {
             $this->log("Putting back in queue");
             $this->queue->release($job);
         } else {
             $this->log("Putting job on hold");
             $this->queue->bury($job);
         }
     }
 }
예제 #3
0
 public function testCreateFromPayload()
 {
     $job = new Job($this->job_name, $this->job_data);
     $job2 = Job::createFromPayload($job->getPayload());
     $this->assertEquals($job, $job2);
 }
예제 #4
0
 public function countReserves(Job $job)
 {
     $stats = $this->pheanstalk->statsJob($job->getId());
     return $stats->reserves;
 }