Skip to content

Commit

Permalink
[minor] support Symfony 6.1 (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
kbond authored Apr 16, 2022
1 parent 7c8a225 commit 191e113
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 11 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ jobs:
- php: 8.1
deps: hightest
symfony: 6.0.*
- php: 8.1
deps: hightest
symfony: 6.1.*
steps:
- uses: zenstruck/.github@php-test-symfony
with:
Expand Down
14 changes: 11 additions & 3 deletions src/Command/ScheduleListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
*/
final class ScheduleListCommand extends Command
{
protected static $defaultName = 'schedule:list';

/** @var ScheduleRunner */
private $scheduleRunner;

Expand All @@ -36,10 +34,20 @@ public function __construct(ScheduleRunner $scheduleRunner, ExtensionHandlerRegi
parent::__construct();
}

public static function getDefaultName(): string
{
return 'schedule:list';
}

public static function getDefaultDescription(): string
{
return 'List configured scheduled tasks';
}

protected function configure(): void
{
$this
->setDescription('List configured scheduled tasks')
->setDescription(self::getDefaultDescription()) // required for Symfony 4.4
->addOption('detail', null, null, 'Show detailed task list')
->setHelp(<<<EOF
Exit code 0: no issues.
Expand Down
14 changes: 11 additions & 3 deletions src/Command/ScheduleRunCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
*/
final class ScheduleRunCommand extends Command
{
protected static $defaultName = 'schedule:run';

/** @var ScheduleRunner */
private $scheduleRunner;

Expand All @@ -32,10 +30,20 @@ public function __construct(ScheduleRunner $scheduleRunner, EventDispatcherInter
parent::__construct();
}

public static function getDefaultName(): string
{
return 'schedule:run';
}

public static function getDefaultDescription(): string
{
return 'Runs scheduled tasks that are due';
}

protected function configure(): void
{
$this
->setDescription('Runs scheduled tasks that are due')
->setDescription(self::getDefaultDescription()) // required for Symfony 4.4
->addArgument('id', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, '(optional) Task ID\'s to "force" run')
->setHelp(<<<EOF
If no arguments are passed, all the tasks currently due are run. Pass one or
Expand Down
5 changes: 4 additions & 1 deletion tests/Command/ScheduleListCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,10 @@ public function command_task_with_invalid_argument_shows_as_error()

$application = new Application();
$application->add(new class() extends Command {
protected static $defaultName = 'my:command';
public static function getDefaultName(): string
{
return 'my:command';
}

protected function configure()
{
Expand Down
5 changes: 4 additions & 1 deletion tests/Fixture/ScheduledCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@
#[AsScheduledTask('@monthly', arguments: '-vv --no-interaction')]
final class ScheduledCommand extends Command
{
protected static $defaultName = 'my:command';
public static function getDefaultName(): string
{
return 'my:command';
}
}
5 changes: 4 additions & 1 deletion tests/Schedule/SelfSchedulingCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ final class SelfSchedulingCommandTest extends TestCase
public function commands_can_self_schedule()
{
$command = new class() extends Command implements SelfSchedulingCommand {
protected static $defaultName = 'my:command';
public static function getDefaultName(): string
{
return 'my:command';
}

public function schedule(CommandTask $task): void
{
Expand Down
5 changes: 4 additions & 1 deletion tests/Schedule/Task/CommandTaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,8 @@ public function unregistered_command_throws_exception()

final class DummyCommand extends Command
{
protected static $defaultName = 'dummy:command';
public static function getDefaultName(): string
{
return 'dummy:command';
}
}
5 changes: 4 additions & 1 deletion tests/Schedule/Task/Runner/CommandTaskRunnerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@ public function supports_command_task()
private function createCommand(): Command
{
return new class() extends Command {
protected static $defaultName = 'my:command';
public static function getDefaultName(): string
{
return 'my:command';
}

protected function configure()
{
Expand Down

0 comments on commit 191e113

Please sign in to comment.