BatchFake.php
3 weeks ago
BatchRepositoryFake.php
3 weeks ago
BusFake.php
3 weeks ago
EventFake.php
3 weeks ago
MailFake.php
3 weeks ago
NotificationFake.php
3 weeks ago
PendingBatchFake.php
3 weeks ago
PendingChainFake.php
2 years ago
PendingMailFake.php
2 years ago
QueueFake.php
3 weeks ago
PendingChainFake.php
53 lines
| 1 | <?php |
| 2 | |
| 3 | namespace IAWPSCOPED\Illuminate\Support\Testing\Fakes; |
| 4 | |
| 5 | use Closure; |
| 6 | use IAWPSCOPED\Illuminate\Foundation\Bus\PendingChain; |
| 7 | use IAWPSCOPED\Illuminate\Queue\CallQueuedClosure; |
| 8 | /** @internal */ |
| 9 | class PendingChainFake extends PendingChain |
| 10 | { |
| 11 | /** |
| 12 | * The fake bus instance. |
| 13 | * |
| 14 | * @var \Illuminate\Support\Testing\Fakes\BusFake |
| 15 | */ |
| 16 | protected $bus; |
| 17 | /** |
| 18 | * Create a new pending chain instance. |
| 19 | * |
| 20 | * @param \Illuminate\Support\Testing\Fakes\BusFake $bus |
| 21 | * @param mixed $job |
| 22 | * @param array $chain |
| 23 | * @return void |
| 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 | * Dispatch the job with the given arguments. |
| 33 | * |
| 34 | * @return \Illuminate\Foundation\Bus\PendingDispatch |
| 35 | */ |
| 36 | public function dispatch() |
| 37 | { |
| 38 | if (\is_string($this->job)) { |
| 39 | $firstJob = new $this->job(...\func_get_args()); |
| 40 | } elseif ($this->job instanceof Closure) { |
| 41 | $firstJob = CallQueuedClosure::create($this->job); |
| 42 | } else { |
| 43 | $firstJob = $this->job; |
| 44 | } |
| 45 | $firstJob->allOnConnection($this->connection); |
| 46 | $firstJob->allOnQueue($this->queue); |
| 47 | $firstJob->chain($this->chain); |
| 48 | $firstJob->delay($this->delay); |
| 49 | $firstJob->chainCatchCallbacks = $this->catchCallbacks(); |
| 50 | return $this->bus->dispatch($firstJob); |
| 51 | } |
| 52 | } |
| 53 |