diff --git a/Command/ListCommand.php b/Command/ListCommand.php index 340c205..a72bbbc 100644 --- a/Command/ListCommand.php +++ b/Command/ListCommand.php @@ -60,7 +60,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $row = [($id + 1), get_class($task)]; if ($showRunDates) { - $nextRunDates = $task->getNextRunDates($numberOfRunDates); + $nextRunDates = $task->getNextRunDates(intval($numberOfRunDates)); $row[] = implode(', ', $nextRunDates); } diff --git a/Tests/Command/ListCommandTest.php b/Tests/Command/ListCommandTest.php index f0c6707..8d3e482 100644 --- a/Tests/Command/ListCommandTest.php +++ b/Tests/Command/ListCommandTest.php @@ -72,4 +72,32 @@ public function testListCommandWithOption(): void $output ); } + + public function testListCommandWithStringOption(): void + { + $container = $this->loadContainer(); + $scheduler = $container->get('ts.scheduler'); + $scheduler->addTask(new TaskMock()); + + $application = new Application(); + /** @var Scheduler $scheduler */ + $application->add(new ListCommand($scheduler)); + + $command = $application->find('ts:list'); + + $runDates = random_int(2, 32); + + $commandTester = new CommandTester($command); + $commandTester->execute([ + 'command' => $command->getName(), + '--show-run-dates' => (string) $runDates, + ]); + + $output = $commandTester->getDisplay(); + $this->assertStringContainsString($runDates . ' run dates', $output); + $this->assertStringContainsString( + '| 1 | Rewieer\TaskSchedulerBundle\Tests\TaskMock | nextRunDate, anotherRunDate', + $output + ); + } }