Skip to content

Commit 7353af9

Browse files
committed
Add enqueueUsing fallback for Laravel 6x and 7x
1 parent 2a85fd4 commit 7353af9

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/CloudTasksQueue.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,25 @@ public function size($queue = null)
4242
return 0;
4343
}
4444

45+
/**
46+
* Fallback method for Laravel 6x and 7x
47+
*
48+
* @param \Closure|string|object $job
49+
* @param string $payload
50+
* @param string $queue
51+
* @param \DateTimeInterface|\DateInterval|int|null $delay
52+
* @param callable $callback
53+
* @return mixed
54+
*/
55+
protected function enqueueUsing($job, $payload, $queue, $delay, $callback)
56+
{
57+
if (method_exists(parent::class, 'enqueueUsing')) {
58+
return parent::enqueueUsing($job, $payload, $queue, $delay, $callback);
59+
}
60+
61+
return $callback($payload, $queue, $delay);
62+
}
63+
4564
/**
4665
* Push a new job onto the queue.
4766
*

tests/QueueTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@ public function it_posts_the_task_the_correct_queue()
163163
*/
164164
public function it_can_dispatch_after_commit()
165165
{
166+
if (version_compare(app()->version(), '8.0.0', '<')) {
167+
$this->markTestSkipped('Not supported by Laravel 7.x and below.');
168+
}
169+
166170
// Arrange
167171
CloudTasksApi::fake();
168172
Event::fake();

0 commit comments

Comments
 (0)