mirror of
https://github.com/idanoo/php-resque
synced 2025-07-01 13:42:22 +00:00
Making the factory the default layer to construct jobs
This commit is contained in:
parent
df20186c37
commit
be19e12c31
5 changed files with 64 additions and 29 deletions
|
@ -31,7 +31,7 @@ class Resque_Tests_EventTest extends Resque_Tests_TestCase
|
|||
$payload = array(
|
||||
'class' => 'Test_Job',
|
||||
'args' => array(
|
||||
'somevar',
|
||||
array('somevar'),
|
||||
),
|
||||
);
|
||||
$job = new Resque_Job('jobs', $payload);
|
||||
|
|
|
@ -362,13 +362,24 @@ class Resque_Tests_JobTest extends Resque_Tests_TestCase
|
|||
$this->assertEquals(Resque::size($queue), 2);
|
||||
}
|
||||
|
||||
public function testUseFactoryToGetJobInstance()
|
||||
public function testUseDefaultFactoryToGetJobInstance()
|
||||
{
|
||||
$payload = array(
|
||||
'class' => 'Some_Job_Class',
|
||||
'args' => null
|
||||
);
|
||||
$job = new Resque_Job('jobs', $payload);
|
||||
$instance = $job->getInstance();
|
||||
$this->assertInstanceOf('Some_Job_Class', $instance);
|
||||
}
|
||||
|
||||
public function testUseFactoryToGetJobInstance()
|
||||
{
|
||||
$payload = array(
|
||||
'class' => 'Some_Job_Class',
|
||||
'args' => array(array())
|
||||
);
|
||||
$job = new Resque_Job('jobs', $payload);
|
||||
$factory = new Some_Stub_Factory();
|
||||
$job->setJobFactory($factory);
|
||||
$instance = $job->getInstance();
|
||||
|
@ -379,7 +390,7 @@ class Resque_Tests_JobTest extends Resque_Tests_TestCase
|
|||
{
|
||||
$payload = array(
|
||||
'class' => 'Some_Job_Class',
|
||||
'args' => null
|
||||
'args' => array(array())
|
||||
);
|
||||
$job = new Resque_Job('jobs', $payload);
|
||||
$factory = $this->getMock('Resque_Job_FactoryInterface');
|
||||
|
@ -411,7 +422,7 @@ class Some_Stub_Factory implements Resque_Job_FactoryInterface
|
|||
* @param $queue
|
||||
* @return Resque_JobInterface
|
||||
*/
|
||||
public function create($className, array $args, $queue)
|
||||
public function create($className, $args, $queue)
|
||||
{
|
||||
return new Some_Job_Class();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue