Skip to content

Commit f5e44cf

Browse files
authored
chore: fix data provider name and order by cs-fix (#191)
1 parent 6542fe6 commit f5e44cf

File tree

2 files changed

+51
-51
lines changed

2 files changed

+51
-51
lines changed

tests/unit/CronExpressionTest.php

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

tests/unit/TaskLogTest.php

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,28 @@
2222
*/
2323
final class TaskLogTest extends TestCase
2424
{
25+
/**
26+
* @param array|bool|int|string|null $output
27+
*
28+
* @throws Exception
29+
*/
30+
#[DataProvider('provideDuration')]
31+
public function testDuration(string $start, string $end, string $expected, $output)
32+
{
33+
$start = new Time($start);
34+
$end = new Time($end);
35+
36+
$log = new TaskLog([
37+
'task' => new Task('closure', static function () {}),
38+
'output' => $output,
39+
'runStart' => $start,
40+
'runEnd' => $end,
41+
'error' => null,
42+
]);
43+
44+
$this->assertSame($expected, $log->duration());
45+
}
46+
2547
public static function provideDuration(): iterable
2648
{
2749
return [
@@ -45,26 +67,4 @@ public static function provideDuration(): iterable
4567
],
4668
];
4769
}
48-
49-
/**
50-
* @param array|bool|int|string|null $output
51-
*
52-
* @throws Exception
53-
*/
54-
#[DataProvider('provideDuration')]
55-
public function testDuration(string $start, string $end, string $expected, $output)
56-
{
57-
$start = new Time($start);
58-
$end = new Time($end);
59-
60-
$log = new TaskLog([
61-
'task' => new Task('closure', static function () {}),
62-
'output' => $output,
63-
'runStart' => $start,
64-
'runEnd' => $end,
65-
'error' => null,
66-
]);
67-
68-
$this->assertSame($expected, $log->duration());
69-
}
7070
}

0 commit comments

Comments
 (0)