예제 #1
0
 public function testAfterEnqueueEventCallbackFires()
 {
     $callback = 'afterEnqueueEventCallback';
     $event = 'afterEnqueue';
     Event::listen($event, array($this, $callback));
     Resque::enqueue('jobs', 'Test_Job', array('somevar'));
     $this->assertContains($callback, $this->callbacksHit, $event . ' callback (' . $callback . ') was not called');
 }
예제 #2
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());
 }
예제 #3
0
 public function testDequeueNonExistingItem2()
 {
     $queue = 'jobs';
     Resque::enqueue($queue, 'Test_Job_Dequeue1');
     Resque::enqueue($queue, 'Test_Job_Dequeue2');
     Resque::enqueue($queue, 'Test_Job_Dequeue3');
     $this->assertEquals(Resque::size($queue), 3);
     $test = ['Test_Job_Dequeue4', 'Test_Job_Dequeue1'];
     $this->assertEquals(Resque::dequeue($queue, $test), 1);
     $this->assertEquals(Resque::size($queue), 2);
 }
예제 #4
0
 public function testWorkerErasesItsStatsWhenShutdown()
 {
     Resque::enqueue('jobs', 'Test_Job');
     Resque::enqueue('jobs', 'Invalid_Job');
     $worker = new Worker('jobs');
     $worker->work(0);
     $worker->work(0);
     $this->assertEquals(0, $worker->getStat('processed'));
     $this->assertEquals(0, $worker->getStat('failed'));
 }