Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Command/ListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
28 changes: 28 additions & 0 deletions Tests/Command/ListCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change this to the following? Since today, the package also supports Symfony 8, and Application::add has been removed

$application->addCommands([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
);
}
}