Skip to content

Commit

Permalink
add support for breaking change
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Feb 21, 2019
1 parent ba5328f commit b79bb27
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/RedisQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Laravel\Horizon;

use ReflectionMethod;
use Illuminate\Support\Str;
use Laravel\Horizon\Events\JobPushed;
use Laravel\Horizon\Events\JobDeleted;
Expand Down Expand Up @@ -74,7 +75,13 @@ public function pushRaw($payload, $queue = null, array $options = [])
*/
public function later($delay, $job, $data = '', $queue = null)
{
$payload = (new JobPayload($this->createPayload($job, $data)))->prepare($job)->value;
if (count((new ReflectionMethod($this, 'createPayload'))->getParameters()) === 3) {
$payload = $this->createPayload($job, $queue, $data);
} else {
$payload = $this->createPayload($job, $data);
}

$payload = (new JobPayload($payload))->prepare($job)->value;

return tap(parent::laterRaw($delay, $payload, $queue), function () use ($payload, $queue) {
$this->event($this->getQueue($queue), new JobPushed($payload));
Expand Down
7 changes: 7 additions & 0 deletions tests/Feature/QueueProcessingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ public function test_pending_jobs_are_stored_in_pending_job_database()
$this->assertSame('pending', Redis::connection('horizon')->hget($id, 'status'));
}

public function test_pending_delayed_jobs_are_stored_in_pending_job_database()
{
$id = Queue::later(1, new Jobs\BasicJob);
$this->assertEquals(1, $this->recentJobs());
$this->assertSame('pending', Redis::connection('horizon')->hget($id, 'status'));
}

public function test_pending_jobs_are_stored_with_their_tags()
{
$id = Queue::push(new Jobs\BasicJob);
Expand Down

0 comments on commit b79bb27

Please sign in to comment.