Skip to content

Commit de22db6

Browse files
author
Sebastian Machuca
committed
Making it compatible with PHP < 5.5
Making the factory receive the classname
1 parent 7d2ce1b commit de22db6

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

lib/Resque/Job.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ public function getInstance()
182182
}
183183

184184
if ($this->jobFactory !== null) {
185-
$this->instance = $this->jobFactory->create();
185+
$this->instance = $this->jobFactory->create($this->payload['class']);
186186
} else {
187187
$this->instance = new $this->payload['class'];
188188
}

lib/Resque/Job/FactoryInterface.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
interface Resque_Job_FactoryInterface
44
{
55
/**
6+
* @param $className
67
* @return Resque_JobInterface
78
*/
8-
public function create();
9+
public function create($className);
910
}

test/Resque/Tests/JobTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -365,30 +365,30 @@ public function testDequeueItemWithiWrongArg()
365365
public function testUseFactoryToGetJobInstance()
366366
{
367367
$payload = array(
368-
'class' => Some_Job_Class::class,
368+
'class' => 'Some_Job_Class',
369369
'args' => null
370370
);
371371
$job = new Resque_Job('jobs', $payload);
372-
$factory = $this->getMock(Resque_Job_FactoryInterface::class);
372+
$factory = $this->getMock('Resque_Job_FactoryInterface');
373373
$job->setJobFactory($factory);
374-
$testJob = $this->getMock(Resque_JobInterface::class);
374+
$testJob = $this->getMock('Resque_JobInterface');
375375
$factory->expects(self::once())->method('create')->will($this->returnValue($testJob));
376376
$instance = $job->getInstance();
377-
$this->assertInstanceOf(Resque_JobInterface::class, $instance);
377+
$this->assertInstanceOf('Resque_JobInterface', $instance);
378378
}
379379

380380
public function testDoNotUseFactoryToGetInstance()
381381
{
382382
$payload = array(
383-
'class' => Some_Job_Class::class,
383+
'class' => 'Some_Job_Class',
384384
'args' => null
385385
);
386386
$job = new Resque_Job('jobs', $payload);
387-
$factory = $this->getMock(Resque_Job_FactoryInterface::class);
388-
$testJob = $this->getMock(Resque_JobInterface::class);
387+
$factory = $this->getMock('Resque_Job_FactoryInterface');
388+
$testJob = $this->getMock('Resque_JobInterface');
389389
$factory->expects(self::never())->method('create')->will(self::returnValue($testJob));
390390
$instance = $job->getInstance();
391-
$this->assertInstanceOf(Resque_JobInterface::class, $instance);
391+
$this->assertInstanceOf('Resque_JobInterface', $instance);
392392
}
393393
}
394394

0 commit comments

Comments
 (0)