@@ -154,6 +154,28 @@ public function testEveryHour($hourTrue, $hourFalse)
154154 $ this ->assertFalse ($ this ->cron ->shouldRun ('00 * * * * ' ));
155155 }
156156
157+ public static function provideEveryHour (): iterable
158+ {
159+ $ hours24 = array_map (static fn ($ h ) => [
160+ $ h . ':00 ' ,
161+ $ h . ':10 ' ,
162+ ], range (0 , 23 ));
163+ $ hoursAM = array_map (static fn ($ h ) => [
164+ $ h . ':00 AM ' ,
165+ $ h . ':10 AM ' ,
166+ ], range (1 , 12 ));
167+ $ hoursPM = array_map (static fn ($ h ) => [
168+ $ h . ':00 PM ' ,
169+ $ h . ':10 PM ' ,
170+ ], range (1 , 12 ));
171+
172+ return [
173+ ...$ hours24 ,
174+ ...$ hoursAM ,
175+ ...$ hoursPM ,
176+ ];
177+ }
178+
157179 public function testQuarterPastHour ()
158180 {
159181 $ this ->cron ->testTime ('6:15 PM ' );
@@ -192,26 +214,15 @@ public function testEveryWeekdayInMonth()
192214 $ this ->assertFalse ($ this ->cron ->shouldRun ('0 20 * 10 1-5 ' ));
193215 }
194216
195- public static function provideEveryHour (): iterable
217+ #[DataProvider('provideNextRun ' )]
218+ public function testNextRun (string $ exp , string $ expected )
196219 {
197- $ hours24 = array_map (static fn ($ h ) => [
198- $ h . ':00 ' ,
199- $ h . ':10 ' ,
200- ], range (0 , 23 ));
201- $ hoursAM = array_map (static fn ($ h ) => [
202- $ h . ':00 AM ' ,
203- $ h . ':10 AM ' ,
204- ], range (1 , 12 ));
205- $ hoursPM = array_map (static fn ($ h ) => [
206- $ h . ':00 PM ' ,
207- $ h . ':10 PM ' ,
208- ], range (1 , 12 ));
220+ $ this ->cron ->testTime ('October 5, 2020 8:00 pm ' );
209221
210- return [
211- ...$ hours24 ,
212- ...$ hoursAM ,
213- ...$ hoursPM ,
214- ];
222+ $ next = $ this ->cron ->nextRun ($ exp );
223+
224+ $ this ->assertInstanceOf (Time::class, $ next );
225+ $ this ->assertSame ($ expected , $ next ->format ('F j, Y g:i a ' ));
215226 }
216227
217228 public static function provideNextRun (): iterable
@@ -237,15 +248,4 @@ public static function provideNextRun(): iterable
237248 ['* * * * 6,0 ' , 'October 9, 2020 8:00 pm ' ],
238249 ];
239250 }
240-
241- #[DataProvider('provideNextRun ' )]
242- public function testNextRun (string $ exp , string $ expected )
243- {
244- $ this ->cron ->testTime ('October 5, 2020 8:00 pm ' );
245-
246- $ next = $ this ->cron ->nextRun ($ exp );
247-
248- $ this ->assertInstanceOf (Time::class, $ next );
249- $ this ->assertSame ($ expected , $ next ->format ('F j, Y g:i a ' ));
250- }
251251}
0 commit comments