Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[10.x] Fix schedule:list to display named Jobs #47367

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/Illuminate/Console/Scheduling/ScheduleListCommand.php
Expand Up @@ -81,10 +81,9 @@ public function handle(Schedule $schedule)
}

if ($event instanceof CallbackEvent) {
if (class_exists($description)) {
$command = $description;
$description = '';
} else {
$command = $event->getSummaryForDisplay();

if (in_array($command, ['Closure', 'Callback'])) {
$command = 'Closure at: '.$this->getClosureLocation($event);
}
}
Expand Down
23 changes: 21 additions & 2 deletions tests/Integration/Console/Scheduling/ScheduleListCommandTest.php
Expand Up @@ -36,6 +36,9 @@ public function testDisplaySchedule()
$this->schedule->command('inspire')->twiceDaily(14, 18);
$this->schedule->command('foobar', ['a' => 'b'])->everyMinute();
$this->schedule->job(FooJob::class)->everyMinute();
$this->schedule->job(new FooParamJob('test'))->everyMinute();
$this->schedule->job(FooJob::class)->name('foo-named-job')->everyMinute();
$this->schedule->job(new FooParamJob('test'))->name('foo-named-param-job')->everyMinute();
$this->schedule->command('inspire')->cron('0 9,17 * * *');
$this->schedule->command('inspire')->cron("0 10\t* * *");
$this->schedule->call(FooCall::class)->everyMinute();
Expand All @@ -51,9 +54,12 @@ public function testDisplaySchedule()
->expectsOutput(' 0 14,18 * * * php artisan inspire ........ Next Due: 14 hours from now')
->expectsOutput(' * * * * * php artisan foobar a='.ProcessUtils::escapeArgument('b').' ... Next Due: 1 minute from now')
->expectsOutput(' * * * * * Illuminate\Tests\Integration\Console\Scheduling\FooJob Next Due: 1 minute from now')
->expectsOutput(' * * * * * Illuminate\Tests\Integration\Console\Scheduling\FooParamJob Next Due: 1 minute from now')
->expectsOutput(' * * * * * foo-named-job .............. Next Due: 1 minute from now')
->expectsOutput(' * * * * * foo-named-param-job ........ Next Due: 1 minute from now')
->expectsOutput(' 0 9,17 * * * php artisan inspire ......... Next Due: 9 hours from now')
->expectsOutput(' 0 10 * * * php artisan inspire ........ Next Due: 10 hours from now')
->expectsOutput(' * * * * * Closure at: Illuminate\Tests\Integration\Console\Scheduling\FooCall Next Due: 1 minute from now')
->expectsOutput(' * * * * * Illuminate\Tests\Integration\Console\Scheduling\FooCall Next Due: 1 minute from now')
->expectsOutput(' * * * * * Closure at: Illuminate\Tests\Integration\Console\Scheduling\FooCall::fooFunction Next Due: 1 minute from now')
->expectsOutput(' * * * * * Closure at: '.$closureFilePath.':'.$closureLineNumber.' Next Due: 1 minute from now');
}
Expand All @@ -64,6 +70,9 @@ public function testDisplayScheduleWithSort()
$this->schedule->command('inspire')->twiceDaily(14, 18);
$this->schedule->command('foobar', ['a' => 'b'])->everyMinute();
$this->schedule->job(FooJob::class)->everyMinute();
$this->schedule->job(new FooParamJob('test'))->everyMinute();
$this->schedule->job(FooJob::class)->name('foo-named-job')->everyMinute();
$this->schedule->job(new FooParamJob('test'))->name('foo-named-param-job')->everyMinute();
$this->schedule->command('inspire')->cron('0 9,17 * * *');
$this->schedule->command('inspire')->cron("0 10\t* * *");
$this->schedule->call(FooCall::class)->everyMinute();
Expand All @@ -77,7 +86,10 @@ public function testDisplayScheduleWithSort()
->assertSuccessful()
->expectsOutput(' * * * * * php artisan foobar a='.ProcessUtils::escapeArgument('b').' ... Next Due: 1 minute from now')
->expectsOutput(' * * * * * Illuminate\Tests\Integration\Console\Scheduling\FooJob Next Due: 1 minute from now')
->expectsOutput(' * * * * * Closure at: Illuminate\Tests\Integration\Console\Scheduling\FooCall Next Due: 1 minute from now')
->expectsOutput(' * * * * * Illuminate\Tests\Integration\Console\Scheduling\FooParamJob Next Due: 1 minute from now')
->expectsOutput(' * * * * * foo-named-job .............. Next Due: 1 minute from now')
->expectsOutput(' * * * * * foo-named-param-job ........ Next Due: 1 minute from now')
->expectsOutput(' * * * * * Illuminate\Tests\Integration\Console\Scheduling\FooCall Next Due: 1 minute from now')
->expectsOutput(' * * * * * Closure at: Illuminate\Tests\Integration\Console\Scheduling\FooCall::fooFunction Next Due: 1 minute from now')
->expectsOutput(' * * * * * Closure at: '.$closureFilePath.':'.$closureLineNumber.' Next Due: 1 minute from now')
->expectsOutput(' 0 9,17 * * * php artisan inspire ......... Next Due: 9 hours from now')
Expand Down Expand Up @@ -117,6 +129,13 @@ class FooJob
{
}

class FooParamJob
{
public function __construct($param)
{
}
}

class FooCall
{
public function __invoke(): void
Expand Down