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
4 changes: 3 additions & 1 deletion src/Schedule/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ public function description()
try {
$reflection = new \ReflectionClass($this->className());
return (string) Arr::get($reflection->getDefaultProperties(), 'description', '');
} catch (\InvalidArgumentException $exception) {
return $this->event->description;
} catch (\ReflectionException $exception) {
return '';
return $this->event->description;
}
}

Expand Down
8 changes: 5 additions & 3 deletions tests/Fakes/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,16 @@ protected function schedule(Schedule $schedule)

if (Arr::has($job, 'job')) {
$command = $schedule->job($job['job']);
} else {
} else if (Arr::has($job, 'command')) {
$command = $schedule->command($job['command']);
} else if (Arr::has($job, 'exec')) {
$command = $schedule->exec($job['exec']);
}

$command->{$job['schedule']}();

collect(Arr::get($job, 'additionalOptions', []))->each(function ($additionalOption) use ($command) {
$command->{$additionalOption}();
collect(Arr::get($job, 'additionalOptions', []))->each(function ($parameter, $additionalOption) use ($command) {
$command->{$additionalOption}($parameter);
});
});
}
Expand Down
28 changes: 23 additions & 5 deletions tests/ListJobsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,23 @@ public function itReturnsAListOfScheduledJobs()
'command' => 'store-fake-metrics',
'schedule' => 'hourly',
'additionalOptions' => [
'withoutOverlapping',
'onOneServer',
'evenInMaintenanceMode'
'withoutOverlapping' => null,
'onOneServer' => null,
'evenInMaintenanceMode' => null
]
],
[
'exec' => 'df',
'schedule' => 'hourly',
'additionalOptions' => [
'description' => 'Check disk usage',
]
],
[
'job' => UpdateOrders::class,
'schedule' => 'daily',
'additionalOptions' => [
'evenInMaintenanceMode'
'evenInMaintenanceMode' => null
]
],
],
Expand All @@ -67,7 +74,7 @@ public function itReturnsAListOfScheduledJobs()
],
[
'command' => 'store-fake-metrics',
'description' => '',
'description' => null,
'expression' => '0 * * * *',
'humanReadableExpression' => 'At the hour past every hour on every day.',
'nextRunAt' => Cron::nextRunAt('0 * * * *')->toIso8601String(),
Expand All @@ -76,6 +83,17 @@ public function itReturnsAListOfScheduledJobs()
'onOneServer' => true,
'evenInMaintenanceMode' => true,
],
[
'command' => null,
'description' => 'Check disk usage',
'expression' => '0 * * * *',
'humanReadableExpression' => 'At the hour past every hour on every day.',
'nextRunAt' => Cron::nextRunAt('0 * * * *')->toIso8601String(),
'timezone' => 'UTC',
'withoutOverlapping' => false,
'onOneServer' => false,
'evenInMaintenanceMode' => false,
],
[
'command' => UpdateOrders::class,
'description' => 'Fake job to update orders...',
Expand Down