示例#1
0
 public function testRecreatedJobWithTrackingStillTracksStatus()
 {
     $originalToken = Resque::enqueue('jobs', 'Test_Job', null, true);
     $job = $this->worker->reserve();
     // Mark this job as being worked on to ensure that the new status is still
     // waiting.
     $this->worker->workingOn($job);
     // Now recreate it
     $newToken = $job->recreate();
     // Make sure we've got a new job returned
     $this->assertNotEquals($originalToken, $newToken);
     // Now check the status of the new job
     $newJob = Job::reserve('jobs');
     $this->assertEquals(Status::STATUS_WAITING, $newJob->getStatus());
 }
示例#2
0
 /**
  * @expectedException PhpResque\Resque\Exception
  */
 public function testInvalidJobThrowsException()
 {
     Resque::enqueue('jobs', 'Invalid_Job');
     $job = $this->worker->reserve();
     $job->worker = $this->worker;
     $job->perform();
 }
示例#3
0
 public function testWorkerLogWithISOTime()
 {
     $worker = new Worker('jobs');
     $worker->logLevel = Worker::LOG_NORMAL;
     $worker->logOutput = fopen('php://memory', 'r+');
     $message = array('message' => 'x', 'data' => '');
     $now = date('c');
     $this->assertEquals(true, $worker->log($message, Worker::LOG_TYPE_INFO));
     rewind($worker->logOutput);
     $output = stream_get_contents($worker->logOutput);
     $lines = explode("\n", $output);
     $this->assertEquals(1, count($lines) - 1);
     $this->assertEquals('[' . $now . '] x', $lines[0]);
 }