Get the instantiated object for this job that will be performing work.
public getInstance ( ) : Resque_JobInterface | ||
Résultat | Resque_JobInterface | Instance of the object that this job belongs to. |
public function getCurrentJob() { $job = $this->worker->job(); if (!$job) { return null; } $job = new \Resque_Job($job['queue'], $job['payload']); return $job->getInstance(); }
public function testDoNotUseFactoryToGetInstance() { $payload = array('class' => 'Some_Job_Class', 'args' => array(array())); $job = new Resque_Job('jobs', $payload); $factory = $this->getMock('Resque_Job_FactoryInterface'); $testJob = $this->getMock('Resque_JobInterface'); $factory->expects(self::never())->method('create')->will(self::returnValue($testJob)); $instance = $job->getInstance(); $this->assertInstanceOf('Resque_JobInterface', $instance); }