File tree 2 files changed +69
-0
lines changed
src/Illuminate/Support/Testing/Fakes
2 files changed +69
-0
lines changed Original file line number Diff line number Diff line change @@ -360,6 +360,19 @@ public function dispatchAfterResponse($command)
360
360
}
361
361
}
362
362
363
+ /**
364
+ * Create a new chain of queueable jobs.
365
+ *
366
+ * @param \Illuminate\Support\Collection|array $jobs
367
+ * @return \Illuminate\Foundation\Bus\PendingChain
368
+ */
369
+ public function chain ($ jobs )
370
+ {
371
+ $ jobs = Collection::wrap ($ jobs );
372
+
373
+ return new PendingChainFake ($ this , $ jobs ->shift (), $ jobs ->toArray ());
374
+ }
375
+
363
376
/**
364
377
* Attempt to find the batch with the given ID.
365
378
*
Original file line number Diff line number Diff line change
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
+ * The fake bus instance.
13
+ *
14
+ * @var \Illuminate\Support\Testing\Fakes\BusFake
15
+ */
16
+ protected $ bus ;
17
+
18
+ /**
19
+ * Create a new pending chain instance.
20
+ *
21
+ * @param \Illuminate\Support\Testing\Fakes\BusFake $bus
22
+ * @param mixed $job
23
+ * @param array $chain
24
+ * @return void
25
+ */
26
+ public function __construct (BusFake $ bus , $ job , $ chain )
27
+ {
28
+ $ this ->bus = $ bus ;
29
+ $ this ->job = $ job ;
30
+ $ this ->chain = $ chain ;
31
+ }
32
+
33
+ /**
34
+ * Dispatch the job with the given arguments.
35
+ *
36
+ * @return \Illuminate\Foundation\Bus\PendingDispatch
37
+ */
38
+ public function dispatch ()
39
+ {
40
+ if (is_string ($ this ->job )) {
41
+ $ firstJob = new $ this ->job (...func_get_args ());
42
+ } elseif ($ this ->job instanceof Closure) {
43
+ $ firstJob = CallQueuedClosure::create ($ this ->job );
44
+ } else {
45
+ $ firstJob = $ this ->job ;
46
+ }
47
+
48
+ $ firstJob ->allOnConnection ($ this ->connection );
49
+ $ firstJob ->allOnQueue ($ this ->queue );
50
+ $ firstJob ->chain ($ this ->chain );
51
+ $ firstJob ->delay ($ this ->delay );
52
+ $ firstJob ->chainCatchCallbacks = $ this ->catchCallbacks ();
53
+
54
+ return $ this ->bus ->dispatch ($ firstJob );
55
+ }
56
+ }
You can’t perform that action at this time.
0 commit comments