File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change 44
55namespace Kapersoft \Knocker \Commands ;
66
7+ use RuntimeException ;
78use Closure ;
89use Illuminate \Console \Command ;
910use Illuminate \Console \Scheduling \CallbackEvent ;
@@ -96,8 +97,11 @@ private function getCallbackCommand(CallbackEvent $event): string
9697 $ closureVariables = $ function ->getClosureUsedVariables ();
9798
9899 if ($ closureCalledClass ->getName () === \Illuminate \Console \Scheduling \Schedule::class && isset ($ closureVariables ['job ' ])) {
99- return $ closureVariables ['job ' ]::class;
100-
100+ return match (true ) {
101+ is_string ($ closureVariables ['job ' ]) => $ closureVariables ['job ' ],
102+ is_object ($ closureVariables ['job ' ]) => $ closureVariables ['job ' ]::class,
103+ default => throw new RuntimeException ('Invalid job type ' ),
104+ };
101105 }
102106
103107 return sprintf (
Original file line number Diff line number Diff line change 4444 Schedule::job (new SendEmails )
4545 ->description ('Job SendEmails ' )
4646 ->hourlyAt ('35 ' );
47+ Schedule::job (SendEmails::class)
48+ ->monthlyOn (1 , '06:00 ' )
49+ ->timezone ('Europe/Amsterdam ' );
4750
4851 Http::fake ([
4952 'https://knocker.laravel.cloud/api/v1/schedulerTasks ' => Http::response ([
9497 'description ' => 'Job SendEmails ' ,
9598 'timezone ' => 'UTC ' ,
9699 ],
100+ [
101+ 'cron_expression ' => '0 6 1 * * ' ,
102+ 'command ' => 'Kapersoft\Knocker\Tests\Fixtures\SendEmails ' ,
103+ 'description ' => 'Kapersoft\Knocker\Tests\Fixtures\SendEmails ' ,
104+ 'timezone ' => 'Europe/Amsterdam ' ,
105+ ],
97106 ],
98107 ];
99108 });
You can’t perform that action at this time.
0 commit comments