| 148 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
namespace Illuminate\Support\Facades;
|
|
|
4 |
|
|
|
5 |
use Illuminate\Bus\BatchRepository;
|
|
|
6 |
use Illuminate\Contracts\Bus\Dispatcher as BusDispatcherContract;
|
|
|
7 |
use Illuminate\Foundation\Bus\PendingChain;
|
|
|
8 |
use Illuminate\Support\Testing\Fakes\BusFake;
|
|
|
9 |
|
|
|
10 |
/**
|
|
|
11 |
* @method static mixed dispatch(mixed $command)
|
|
|
12 |
* @method static mixed dispatchSync(mixed $command, mixed $handler = null)
|
|
|
13 |
* @method static mixed dispatchNow(mixed $command, mixed $handler = null)
|
|
|
14 |
* @method static \Illuminate\Bus\Batch|null findBatch(string $batchId)
|
|
|
15 |
* @method static \Illuminate\Bus\PendingBatch batch(\Illuminate\Support\Collection|array|mixed $jobs)
|
|
|
16 |
* @method static \Illuminate\Foundation\Bus\PendingChain chain(\Illuminate\Support\Collection|array $jobs)
|
|
|
17 |
* @method static bool hasCommandHandler(mixed $command)
|
|
|
18 |
* @method static bool|mixed getCommandHandler(mixed $command)
|
|
|
19 |
* @method static mixed dispatchToQueue(mixed $command)
|
|
|
20 |
* @method static void dispatchAfterResponse(mixed $command, mixed $handler = null)
|
|
|
21 |
* @method static \Illuminate\Bus\Dispatcher pipeThrough(array $pipes)
|
|
|
22 |
* @method static \Illuminate\Bus\Dispatcher map(array $map)
|
|
|
23 |
* @method static void except(array|string $jobsToDispatch)
|
|
|
24 |
* @method static void assertDispatched(string|\Closure $command, callable|int|null $callback = null)
|
|
|
25 |
* @method static void assertDispatchedTimes(string $command, int $times = 1)
|
|
|
26 |
* @method static void assertNotDispatched(string|\Closure $command, callable|null $callback = null)
|
|
|
27 |
* @method static void assertNothingDispatched()
|
|
|
28 |
* @method static void assertDispatchedSync(string|\Closure $command, callable|int|null $callback = null)
|
|
|
29 |
* @method static void assertDispatchedSyncTimes(string $command, int $times = 1)
|
|
|
30 |
* @method static void assertNotDispatchedSync(string|\Closure $command, callable|null $callback = null)
|
|
|
31 |
* @method static void assertDispatchedAfterResponse(string|\Closure $command, callable|int|null $callback = null)
|
|
|
32 |
* @method static void assertDispatchedAfterResponseTimes(string $command, int $times = 1)
|
|
|
33 |
* @method static void assertNotDispatchedAfterResponse(string|\Closure $command, callable|null $callback = null)
|
|
|
34 |
* @method static void assertChained(array $expectedChain)
|
|
|
35 |
* @method static void assertDispatchedWithoutChain(string|\Closure $command, callable|null $callback = null)
|
|
|
36 |
* @method static void assertBatched(callable $callback)
|
|
|
37 |
* @method static void assertBatchCount(int $count)
|
|
|
38 |
* @method static void assertNothingBatched()
|
|
|
39 |
* @method static \Illuminate\Support\Collection dispatched(string $command, callable|null $callback = null)
|
|
|
40 |
* @method static \Illuminate\Support\Collection dispatchedSync(string $command, callable|null $callback = null)
|
|
|
41 |
* @method static \Illuminate\Support\Collection dispatchedAfterResponse(string $command, callable|null $callback = null)
|
|
|
42 |
* @method static \Illuminate\Support\Collection batched(callable $callback)
|
|
|
43 |
* @method static bool hasDispatched(string $command)
|
|
|
44 |
* @method static bool hasDispatchedSync(string $command)
|
|
|
45 |
* @method static bool hasDispatchedAfterResponse(string $command)
|
|
|
46 |
* @method static \Illuminate\Bus\Batch dispatchFakeBatch(string $name = '')
|
|
|
47 |
* @method static \Illuminate\Bus\Batch recordPendingBatch(\Illuminate\Bus\PendingBatch $pendingBatch)
|
|
|
48 |
*
|
|
|
49 |
* @see \Illuminate\Bus\Dispatcher
|
|
|
50 |
* @see \Illuminate\Support\Testing\Fakes\BusFake
|
|
|
51 |
*/
|
|
|
52 |
class Bus extends Facade
|
|
|
53 |
{
|
|
|
54 |
/**
|
|
|
55 |
* Replace the bound instance with a fake.
|
|
|
56 |
*
|
|
|
57 |
* @param array|string $jobsToFake
|
|
|
58 |
* @param \Illuminate\Bus\BatchRepository|null $batchRepository
|
|
|
59 |
* @return \Illuminate\Support\Testing\Fakes\BusFake
|
|
|
60 |
*/
|
|
|
61 |
public static function fake($jobsToFake = [], BatchRepository $batchRepository = null)
|
|
|
62 |
{
|
|
|
63 |
static::swap($fake = new BusFake(static::getFacadeRoot(), $jobsToFake, $batchRepository));
|
|
|
64 |
|
|
|
65 |
return $fake;
|
|
|
66 |
}
|
|
|
67 |
|
|
|
68 |
/**
|
|
|
69 |
* Dispatch the given chain of jobs.
|
|
|
70 |
*
|
|
|
71 |
* @param array|mixed $jobs
|
|
|
72 |
* @return \Illuminate\Foundation\Bus\PendingDispatch
|
|
|
73 |
*/
|
|
|
74 |
public static function dispatchChain($jobs)
|
|
|
75 |
{
|
|
|
76 |
$jobs = is_array($jobs) ? $jobs : func_get_args();
|
|
|
77 |
|
|
|
78 |
return (new PendingChain(array_shift($jobs), $jobs))
|
|
|
79 |
->dispatch();
|
|
|
80 |
}
|
|
|
81 |
|
|
|
82 |
/**
|
|
|
83 |
* Get the registered name of the component.
|
|
|
84 |
*
|
|
|
85 |
* @return string
|
|
|
86 |
*/
|
|
|
87 |
protected static function getFacadeAccessor()
|
|
|
88 |
{
|
|
|
89 |
return BusDispatcherContract::class;
|
|
|
90 |
}
|
|
|
91 |
}
|