Skip to content

Commit fc19fd9

Browse files
authored
Merge pull request #97 from phinor/master
Fixes #94 by checking for an array parameter when creating a new Job
2 parents 1dbc93a + 7651656 commit fc19fd9

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/GO/Job.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ public function __construct($command, $args = [], $id = null)
157157
} else {
158158
if (is_string($command)) {
159159
$this->id = md5($command);
160+
} elseif (is_array($command)) {
161+
$this->id = md5(serialize($command));
160162
} else {
161163
/* @var object $command */
162164
$this->id = spl_object_hash($command);

tests/GO/JobTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ public function testShouldAlwaysGenerateAnId()
1414
return true;
1515
});
1616
$this->assertTrue(is_string($job2->getId()));
17+
18+
$job3 = new Job(['MyClass', 'myMethod']);
19+
$this->assertTrue(is_string($job3->getId()));
1720
}
1821

1922
public function testShouldGenerateIdFromSignature()
@@ -23,6 +26,9 @@ public function testShouldGenerateIdFromSignature()
2326

2427
$job2 = new Job('whoami');
2528
$this->assertNotEquals($job1->getId(), $job2->getId());
29+
30+
$job3 = new Job(['MyClass', 'myMethod']);
31+
$this->assertNotEquals($job1->getId(), $job3->getId());
2632
}
2733

2834
public function testShouldAllowCustomId()
@@ -31,6 +37,9 @@ public function testShouldAllowCustomId()
3137

3238
$this->assertNotEquals(md5('ls'), $job->getId());
3339
$this->assertEquals('aCustomId', $job->getId());
40+
41+
$job2 = new Job(['MyClass', 'myMethod'], null, 'myCustomId');
42+
$this->assertEquals('myCustomId', $job2->getId());
3443
}
3544

3645
public function testShouldKnowIfDue()

0 commit comments

Comments
 (0)