| 1 |
<?php |
| 2 |
|
| 3 |
namespace Illuminate\Support\Testing\Fakes; |
| 4 |
|
| 5 |
use Closure; |
| 6 |
use Illuminate\Foundation\Bus\PendingChain; |
| 7 |
use Illuminate\Queue\CallQueuedClosure; |
| 8 |
|
| 9 |
class PendingChainFake extends PendingChain |
| 10 |
{ |
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
protected $bus; |
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
public function __construct(BusFake $bus, $job, $chain) |
| 26 |
{ |
| 27 |
$this->bus = $bus; |
| 28 |
$this->job = $job; |
| 29 |
$this->chain = $chain; |
| 30 |
} |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
public function dispatch() |
| 38 |
{ |
| 39 |
if (is_string($this->job)) { |
| 40 |
$firstJob = new $this->job(...func_get_args()); |
| 41 |
} elseif ($this->job instanceof Closure) { |
| 42 |
$firstJob = CallQueuedClosure::create($this->job); |
| 43 |
} else { |
| 44 |
$firstJob = $this->job; |
| 45 |
} |
| 46 |
|
| 47 |
$firstJob->allOnConnection($this->connection); |
| 48 |
$firstJob->allOnQueue($this->queue); |
| 49 |
$firstJob->chain($this->chain); |
| 50 |
$firstJob->delay($this->delay); |
| 51 |
$firstJob->chainCatchCallbacks = $this->catchCallbacks(); |
| 52 |
|
| 53 |
return $this->bus->dispatch($firstJob); |
| 54 |
} |
| 55 |
} |