forked from resque/php-resque
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJobPIDTest.php
57 lines (47 loc) · 1.23 KB
/
JobPIDTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
namespace Resque\Tests;
use \Resque\Worker\ResqueWorker;
use \Resque\Job\PID;
use \Resque\Resque;
/**
* PID tests.
*
* @package Resque/Tests
* @author Chris Boulton <[email protected]>
* @license http://www.opensource.org/licenses/mit-license.php
*/
class JobPIDTest extends ResqueTestCase
{
/**
* @var \Resque\Worker\ResqueWorker
*/
protected $worker;
public function setUp(): void
{
parent::setUp();
// Register a worker to test with
$this->worker = new ResqueWorker('jobs');
$this->worker->setLogger($this->logger);
}
public function testQueuedJobDoesNotReturnPID()
{
$this->logger->expects($this->never())
->method('log');
$token = Resque::enqueue('jobs', 'Test_Job', null, true);
$this->assertEquals(0, PID::get($token));
}
public function testRunningJobReturnsPID()
{
// Cannot use InProgress_Job on non-forking OS.
if(!function_exists('pcntl_fork')) return;
$token = Resque::enqueue('jobs', 'InProgress_Job', null, true);
$this->worker->work(0);
$this->assertNotEquals(0, PID::get($token));
}
public function testFinishedJobDoesNotReturnPID()
{
$token = Resque::enqueue('jobs', 'Test_Job', null, true);
$this->worker->work(0);
$this->assertEquals(0, PID::get($token));
}
}