File tree Expand file tree Collapse file tree 5 files changed +56
-14
lines changed Expand file tree Collapse file tree 5 files changed +56
-14
lines changed Original file line number Diff line number Diff line change 2020 },
2121 "require" : {
2222 "php" : " ^7.4|^8.0" ,
23+ "illuminate/console" : " ^8.0|^9.0|^10.0" ,
2324 "illuminate/queue" : " ^8.0|^9.0|^10.0" ,
2425 "illuminate/support" : " ^8.0|^9.0|^10.0" ,
2526 "kainxspirits/laravel-pubsub-queue" : " ^0.6|^0.7|^0.8"
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace RichanFongdasen \GCRWorker \Console \Commands ;
4+
5+ use Illuminate \Console \Scheduling \ScheduleRunCommand as BaseScheduleRunCommand ;
6+
7+ class ScheduleRunCommand extends BaseScheduleRunCommand
8+ {
9+ /**
10+ * The console command name.
11+ *
12+ * @var string
13+ */
14+ protected $ name = 'gcr-schedule:run ' ;
15+
16+ /**
17+ * Create a new command instance.
18+ *
19+ * @return void
20+ */
21+ public function __construct ()
22+ {
23+ parent ::__construct ();
24+
25+ $ this ->fixStartTime ();
26+ }
27+
28+ /**
29+ * Fix the start time of the command.
30+ *
31+ * @return void
32+ */
33+ protected function fixStartTime (): void
34+ {
35+ $ this ->startedAt ->second (0 );
36+ }
37+ }
Original file line number Diff line number Diff line change @@ -42,12 +42,10 @@ public function index(): JsonResponse
4242 $ this ->increaseExecutionTime ();
4343 $ this ->increaseMemoryLimit ();
4444
45- Artisan::call ('schedule:run ' );
45+ Artisan::call ('gcr- schedule:run ' );
4646
47- $ response = [
47+ return response ()-> json ( [
4848 'info ' => 'The scheduled job has completed. ' ,
49- ];
50-
51- return response ()->json ($ reponse );
49+ ]);
5250 }
5351}
Original file line number Diff line number Diff line change 44
55use Illuminate \Support \Facades \Route ;
66use Illuminate \Support \ServiceProvider as Provider ;
7+ use RichanFongdasen \GCRWorker \Console \Commands \ScheduleRunCommand ;
78
89class ServiceProvider extends Provider
910{
@@ -33,6 +34,20 @@ public function register(): void
3334 if ($ configPath !== false ) {
3435 $ this ->mergeConfigFrom ($ configPath , 'gcr-worker ' );
3536 }
37+
38+ $ this ->registerCommands ();
39+ }
40+
41+ /**
42+ * Register the package's console commands.
43+ *
44+ * @return void
45+ */
46+ protected function registerCommands (): void
47+ {
48+ $ this ->commands ([
49+ ScheduleRunCommand::class,
50+ ]);
3651 }
3752
3853 /**
Original file line number Diff line number Diff line change @@ -20,15 +20,6 @@ public function it_can_handle_scheduled_job_invocation_as_expected()
2020 {
2121 config (['gcr-worker.allow_event_invocation ' => true ]);
2222
23- $ artisan = \Mockery::mock (Kernel::class);
24- app ()->bind (KernelContract::class, function () use ($ artisan ) {
25- return $ artisan ;
26- });
27-
28- $ artisan ->shouldReceive ('call ' )
29- ->withArgs (['schedule:run ' ])
30- ->once ();
31-
3223 $ this ->getJson ('/gcr-worker/run-scheduled-job ' )
3324 ->assertStatus (200 )
3425 ->assertJsonFragment (['info ' => 'The scheduled job has completed. ' ]);
You can’t perform that action at this time.
0 commit comments