public function testRecreatedJobMatchesExistingJob() { $args = array('int' => 123, 'numArray' => array(1, 2), 'assocArray' => array('key1' => 'value1', 'key2' => 'value2')); Resque::enqueue('jobs', TestJob::className(), $args); $job = Job::reserve('jobs'); // Now recreate it $job->recreate(); $newJob = Job::reserve('jobs'); $this->assertEquals($job->payload['class'], $newJob->payload['class']); $this->assertEquals($job->payload['args'], $newJob->getArguments()); }
public function testRecreatedJobWithTrackingStillTracksStatus() { $originalToken = Resque::enqueue('jobs', TestJob::className(), 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()); }
public function afterEnqueueEventCallback($class, $args) { $this->callbacksHit[] = __FUNCTION__; $this->assertEquals(TestJob::className(), $class); $this->assertEquals(array('somevar'), $args); }
public function testWorkerFailsUncompletedJobsOnExit() { $worker = new Worker('jobs'); $worker->registerWorker(); $payload = array('class' => TestJob::className()); $job = new Job('jobs', $payload); $worker->workingOn($job); $worker->unregisterWorker(); $this->assertEquals(1, Stat::get('failed')); }