diff --git a/src/Illuminate/Foundation/Bus/PendingDispatch.php b/src/Illuminate/Foundation/Bus/PendingDispatch.php index 1e514e5b0b78..ae5136c60b6d 100644 --- a/src/Illuminate/Foundation/Bus/PendingDispatch.php +++ b/src/Illuminate/Foundation/Bus/PendingDispatch.php @@ -100,6 +100,18 @@ public function delay($delay) return $this; } + /** + * Set the delay for the job to zero seconds. + * + * @return $this + */ + public function withoutDelay() + { + $this->job->withoutDelay(); + + return $this; + } + /** * Indicate that the job should be dispatched after all database transactions have committed. * diff --git a/tests/Queue/QueueDelayTest.php b/tests/Queue/QueueDelayTest.php index 9e3d1454a477..3cea13a5090e 100644 --- a/tests/Queue/QueueDelayTest.php +++ b/tests/Queue/QueueDelayTest.php @@ -30,6 +30,17 @@ public function test_queue_without_delay() $this->assertEquals(0, $job->delay); } + + public function test_pending_dispatch_without_delay() + { + Queue::fake(); + + $job = new TestJob; + + dispatch($job)->withoutDelay(); + + $this->assertEquals(0, $job->delay); + } } class TestJob implements ShouldQueue