|
4 | 4 |
|
5 | 5 | namespace JobRunner\JobRunner\SymfonyConsole\Tests\Unit; |
6 | 6 |
|
| 7 | +use DateTimeImmutable; |
7 | 8 | use JobRunner\JobRunner\Job\Job; |
8 | 9 | use JobRunner\JobRunner\SymfonyConsole\SymfonyConsoleEventListener; |
9 | 10 | use PHPUnit\Framework\TestCase; |
@@ -34,18 +35,20 @@ public function testSuccess(): void |
34 | 35 | $table = self::createMock(Table::class); |
35 | 36 | $consoleSectionOutput = self::createMock(ConsoleSectionOutput::class); |
36 | 37 | $job = self::createMock(Job::class); |
| 38 | + $nextHour = (new DateTimeImmutable())->setTime((int) (new DateTimeImmutable())->modify('+1 hour')->format('H'), 0, 0); |
37 | 39 |
|
38 | 40 | $table->expects($this->exactly(5))->method('render'); |
39 | 41 | $job->expects($this->any())->method('getName')->willReturn('myName'); |
| 42 | + $job->expects($this->any())->method('getCronExpression')->willReturn('0 * * * *'); |
40 | 43 | $consoleSectionOutput->expects($this->exactly(5))->method('clear'); |
41 | | - $table->expects($this->once())->method('setHeaders')->with(['Job name', 'state', 'output']); |
42 | | - $table->expects($this->exactly(5))->method('setRows')->with($this->callback(function (mixed $param) { |
| 44 | + $table->expects($this->once())->method('setHeaders')->with(['Job name', 'cron expression', 'next run date', 'state', 'output']); |
| 45 | + $table->expects($this->exactly(5))->method('setRows')->with($this->callback(function (mixed $param) use ($nextHour) { |
43 | 46 | return $param === match ($this->getNextIncrement('setRows')) { |
44 | | - 1 => [['myName', 'start', null]], |
45 | | - 2 => [['myName', 'fail', 'toto']], |
46 | | - 3 => [['myName', 'notDue', null]], |
47 | | - 4 => [['myName', 'isLocked', null]], |
48 | | - 5 => [['myName', 'success', 'toto']], |
| 47 | + 1 => [['myName', '0 * * * *', $nextHour->format('Y-m-d H:i:s'), 'start', null]], |
| 48 | + 2 => [['myName', '0 * * * *', $nextHour->format('Y-m-d H:i:s'), 'fail', 'toto']], |
| 49 | + 3 => [['myName', '0 * * * *', $nextHour->format('Y-m-d H:i:s'), 'notDue', null]], |
| 50 | + 4 => [['myName', '0 * * * *', $nextHour->format('Y-m-d H:i:s'), 'isLocked', null]], |
| 51 | + 5 => [['myName', '0 * * * *', $nextHour->format('Y-m-d H:i:s'), 'success', 'toto']], |
49 | 52 | }; |
50 | 53 | })); |
51 | 54 |
|
|
0 commit comments