File tree Expand file tree Collapse file tree 4 files changed +15
-26
lines changed Expand file tree Collapse file tree 4 files changed +15
-26
lines changed Original file line number Diff line number Diff line change 22.idea /
33.phpunit.result.cache
44.phpunit.cache
5- .env
5+ .env
6+ /coverage
Original file line number Diff line number Diff line change 1616 <env name =" QUEUE_DRIVER" value =" cloudtasks" />
1717 <env name =" DB_DRIVER" value =" mysql" />
1818 </php >
19+ <source >
20+ <include >
21+ <directory suffix =" .php" >./src</directory >
22+ </include >
23+ </source >
1924</phpunit >
Original file line number Diff line number Diff line change 44
55namespace Tests \Support ;
66
7+ use Error ;
78use Illuminate \Support \Facades \Event ;
89use Illuminate \Queue \Events \WorkerStopping ;
10+ use Symfony \Component \ErrorHandler \Error \FatalError ;
911
1012class SimpleJobWithTimeout extends SimpleJob
1113{
1214 public $ timeout = 3 ;
1315
1416 public function handle ()
1517 {
16- Event::listen (WorkerStopping::class, function () {
17- event (new JobOutput ('SimpleJobWithTimeout:worker-stopping ' ));
18- });
19-
20- event (new JobOutput ('SimpleJobWithTimeout:1 ' ));
21- sleep (1 );
22- event (new JobOutput ('SimpleJobWithTimeout:2 ' ));
23- sleep (1 );
24- event (new JobOutput ('SimpleJobWithTimeout:3 ' ));
25- sleep (1 );
26- event (new JobOutput ('SimpleJobWithTimeout:4 ' ));
27- sleep (1 );
28- event (new JobOutput ('SimpleJobWithTimeout:5 ' ));
18+ throw new FatalError ('Maximum execution time of 30 seconds exceeded ' , 500 , [
19+ 'file ' => __FILE__ ,
20+ 'line ' => __LINE__ ,
21+ ]);
2922 }
3023}
Original file line number Diff line number Diff line change @@ -289,23 +289,13 @@ public function retried_jobs_get_a_new_name()
289289 #[Test]
290290 public function test_job_timeout ()
291291 {
292- $ this ->markTestSkipped ('Currently seemingly impossible to test job timeouts. ' );
293-
294292 // Arrange
295- Event::fake (JobOutput ::class);
293+ Event::fake (JobReleasedAfterException ::class);
296294
297295 // Act
298296 $ this ->dispatch (new SimpleJobWithTimeout )->run ();
299297
300298 // Assert
301- $ events = Event::dispatched (JobOutput::class)->map (fn ($ event ) => $ event [0 ]->output )->toArray ();
302- $ this ->assertEquals ([
303- 'SimpleJobWithTimeout:1 ' ,
304- 'SimpleJobWithTimeout:2 ' ,
305- 'SimpleJobWithTimeout:3 ' ,
306- 'SimpleJobWithTimeout:worker-stopping ' ,
307- 'SimpleJobWithTimeout:4 ' ,
308- 'SimpleJobWithTimeout:5 ' ,
309- ], $ events );
299+ Event::assertDispatched (JobReleasedAfterException::class);
310300 }
311301}
You can’t perform that action at this time.
0 commit comments