12
12
13
13
class JobChainingTest extends TestCase
14
14
{
15
- public static $ catchCallbackCount = 0 ;
15
+ public static $ catchCallbackRan = false ;
16
16
17
17
protected function getEnvironmentSetUp ($ app )
18
18
{
@@ -30,6 +30,7 @@ protected function tearDown(): void
30
30
JobChainingTestFirstJob::$ ran = false ;
31
31
JobChainingTestSecondJob::$ ran = false ;
32
32
JobChainingTestThirdJob::$ ran = false ;
33
+ static ::$ catchCallbackRan = false ;
33
34
}
34
35
35
36
public function testJobsCanBeChainedOnSuccess ()
@@ -147,56 +148,19 @@ public function testThirdJobIsNotFiredIfSecondFails()
147
148
148
149
public function testCatchCallbackIsCalledOnFailure ()
149
150
{
150
- self ::$ catchCallbackCount = 0 ;
151
-
152
151
Bus::chain ([
153
152
new JobChainingTestFirstJob ,
154
153
new JobChainingTestFailingJob ,
155
154
new JobChainingTestSecondJob ,
156
155
])->catch (static function () {
157
- self ::$ catchCallbackCount ++ ;
156
+ self ::$ catchCallbackRan = true ;
158
157
})->dispatch ();
159
158
160
159
$ this ->assertTrue (JobChainingTestFirstJob::$ ran );
161
- $ this ->assertSame ( 1 , static ::$ catchCallbackCount );
160
+ $ this ->assertTrue ( static ::$ catchCallbackRan );
162
161
$ this ->assertFalse (JobChainingTestSecondJob::$ ran );
163
162
}
164
163
165
- public function testCatchCallbackIsCalledOnceOnSyncQueue ()
166
- {
167
- self ::$ catchCallbackCount = 0 ;
168
-
169
- try {
170
- Bus::chain ([
171
- new JobChainingTestFirstJob (),
172
- new JobChainingTestThrowJob (),
173
- new JobChainingTestSecondJob (),
174
- ])->catch (function () {
175
- self ::$ catchCallbackCount ++;
176
- })->onConnection ('sync ' )->dispatch ();
177
- } finally {
178
- $ this ->assertTrue (JobChainingTestFirstJob::$ ran );
179
- $ this ->assertSame (1 , static ::$ catchCallbackCount );
180
- $ this ->assertFalse (JobChainingTestSecondJob::$ ran );
181
- }
182
-
183
- self ::$ catchCallbackCount = 0 ;
184
-
185
- try {
186
- Bus::chain ([
187
- new JobChainingTestFirstJob (),
188
- new JobChainingTestThrowJob (),
189
- new JobChainingTestSecondJob (),
190
- ])->catch (function () {
191
- self ::$ catchCallbackCount ++;
192
- })->onConnection ('sync ' )->dispatch ();
193
- } finally {
194
- $ this ->assertTrue (JobChainingTestFirstJob::$ ran );
195
- $ this ->assertSame (1 , static ::$ catchCallbackCount );
196
- $ this ->assertFalse (JobChainingTestSecondJob::$ ran );
197
- }
198
- }
199
-
200
164
public function testChainJobsUseSameConfig ()
201
165
{
202
166
JobChainingTestFirstJob::dispatch ()->allOnQueue ('some_queue ' )->allOnConnection ('sync1 ' )->chain ([
@@ -329,13 +293,3 @@ public function handle()
329
293
$ this ->fail ();
330
294
}
331
295
}
332
-
333
- class JobChainingTestThrowJob implements ShouldQueue
334
- {
335
- use Dispatchable, InteractsWithQueue, Queueable;
336
-
337
- public function handle ()
338
- {
339
- throw new \Exception ();
340
- }
341
- }
0 commit comments