mirror of
https://github.com/idanoo/php-resque
synced 2025-07-01 05:32:20 +00:00
Add setUp and tearDown callbacks for jobs
This commit is contained in:
parent
94fed1cfb4
commit
6e6d7ad859
6 changed files with 114 additions and 3 deletions
|
@ -136,4 +136,36 @@ class Resque_Tests_JobTest extends Resque_Tests_TestCase
|
|||
$job->worker = $this->worker;
|
||||
$job->perform();
|
||||
}
|
||||
|
||||
public function testJobWithSetUpCallbackFiresSetUp()
|
||||
{
|
||||
$payload = array(
|
||||
'class' => 'Test_Job_With_SetUp',
|
||||
'args' => array(
|
||||
'somevar',
|
||||
'somevar2',
|
||||
),
|
||||
);
|
||||
$job = new Resque_Job('jobs', $payload);
|
||||
$job->perform();
|
||||
|
||||
$this->assertTrue(Test_Job_With_SetUp::$called);
|
||||
$this->assertEquals($payload['args'], Test_Job_With_SetUp::$data);
|
||||
}
|
||||
|
||||
public function testJobWithTearDownCallbackFiresSetUp()
|
||||
{
|
||||
$payload = array(
|
||||
'class' => 'Test_Job_With_TearDown',
|
||||
'args' => array(
|
||||
'somevar',
|
||||
'somevar2',
|
||||
),
|
||||
);
|
||||
$job = new Resque_Job('jobs', $payload);
|
||||
$job->perform();
|
||||
|
||||
$this->assertTrue(Test_Job_With_TearDown::$called);
|
||||
$this->assertEquals($payload['args'], Test_Job_With_TearDown::$data);
|
||||
}
|
||||
}
|
|
@ -113,4 +113,39 @@ class Failing_Job
|
|||
class Test_Job_Without_Perform_Method
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
class Test_Job_With_SetUp
|
||||
{
|
||||
public static $called = false;
|
||||
public static $data = false;
|
||||
|
||||
public function setUp($data)
|
||||
{
|
||||
self::$called = true;
|
||||
self::$data = $data;
|
||||
}
|
||||
|
||||
public function perform($data)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class Test_Job_With_TearDown
|
||||
{
|
||||
public static $called = false;
|
||||
public static $data = false;
|
||||
|
||||
public function perform($data)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function tearDown($data)
|
||||
{
|
||||
self::$called = true;
|
||||
self::$data = $data;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue