File tree Expand file tree Collapse file tree 3 files changed +26
-10
lines changed Expand file tree Collapse file tree 3 files changed +26
-10
lines changed Original file line number Diff line number Diff line change @@ -182,13 +182,14 @@ public function getInstance()
182
182
}
183
183
184
184
if ($ this ->jobFactory !== null ) {
185
- $ this ->instance = $ this ->jobFactory ->create ($ this ->payload ['class ' ]);
186
- } else {
187
- $ this ->instance = new $ this ->payload ['class ' ];
185
+ $ this ->instance = $ this ->jobFactory ->create ($ this ->payload ['class ' ], $ this ->getArguments (), $ this ->queue );
186
+ return $ this ->instance ;
188
187
}
189
- $ this ->instance ->job = $ this ;
190
- $ this ->instance ->args = $ this ->getArguments ();
191
- $ this ->instance ->queue = $ this ->queue ;
188
+ $ this ->instance = new $ this ->payload ['class ' ];
189
+ $ this ->instance ->job = $ this ;
190
+ $ this ->instance ->args = $ this ->getArguments ();
191
+ $ this ->instance ->queue = $ this ->queue ;
192
+
192
193
return $ this ->instance ;
193
194
}
194
195
Original file line number Diff line number Diff line change @@ -4,7 +4,9 @@ interface Resque_Job_FactoryInterface
4
4
{
5
5
/**
6
6
* @param $className
7
+ * @param array $args
8
+ * @param $queue
7
9
* @return Resque_JobInterface
8
10
*/
9
- public function create ($ className );
11
+ public function create ($ className, array $ args , $ queue );
10
12
}
Original file line number Diff line number Diff line change @@ -369,10 +369,8 @@ public function testUseFactoryToGetJobInstance()
369
369
'args ' => null
370
370
);
371
371
$ job = new Resque_Job ('jobs ' , $ payload );
372
- $ factory = $ this -> getMock ( ' Resque_Job_FactoryInterface ' );
372
+ $ factory = new Some_Stub_Factory ( );
373
373
$ job ->setJobFactory ($ factory );
374
- $ testJob = $ this ->getMock ('Resque_JobInterface ' );
375
- $ factory ->expects (self ::once ())->method ('create ' )->will ($ this ->returnValue ($ testJob ));
376
374
$ instance = $ job ->getInstance ();
377
375
$ this ->assertInstanceOf ('Resque_JobInterface ' , $ instance );
378
376
}
@@ -403,3 +401,18 @@ public function perform()
403
401
return true ;
404
402
}
405
403
}
404
+
405
+ class Some_Stub_Factory implements Resque_Job_FactoryInterface
406
+ {
407
+
408
+ /**
409
+ * @param $className
410
+ * @param array $args
411
+ * @param $queue
412
+ * @return Resque_JobInterface
413
+ */
414
+ public function create ($ className , array $ args , $ queue )
415
+ {
416
+ return new Some_Job_Class ();
417
+ }
418
+ }
You can’t perform that action at this time.
0 commit comments