Skip to content

[Scheduler] Fix tests #51802

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

Merged
merged 1 commit into from
Oct 2, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
use Symfony\Component\Scheduler\Attribute\AsCronTask;
use Symfony\Component\Scheduler\Attribute\AsPeriodicTask;

#[AsCronTask(expression: '* * * * *', arguments: [1], schedule: 'dummy')]
#[AsCronTask(expression: '0 * * * *', timezone: 'Europe/Berlin', arguments: ['2'], schedule: 'dummy', method: 'method2')]
#[AsPeriodicTask(frequency: 5, arguments: [3], schedule: 'dummy')]
#[AsPeriodicTask(frequency: 'every day', from: '00:00:00', jitter: 60, arguments: ['4'], schedule: 'dummy', method: 'method4')]
#[AsCronTask(expression: '* * * * *', arguments: [1], schedule: 'dummy_task')]
#[AsCronTask(expression: '0 * * * *', timezone: 'Europe/Berlin', arguments: ['2'], schedule: 'dummy_task', method: 'method2')]
#[AsPeriodicTask(frequency: 5, arguments: [3], schedule: 'dummy_task')]
#[AsPeriodicTask(frequency: '1 day', from: '00:00:00', jitter: 60, arguments: ['4'], schedule: 'dummy_task', method: 'method4')]
class DummyTask
{
public static array $calls = [];

#[AsPeriodicTask(frequency: 'every hour', from: '09:00:00', until: '17:00:00', arguments: ['b' => 6, 'a' => '5'], schedule: 'dummy')]
#[AsCronTask(expression: '0 0 * * *', arguments: ['7', 8], schedule: 'dummy')]
#[AsPeriodicTask(frequency: '1 hour', from: '09:00:00', until: '17:00:00', arguments: ['b' => 6, 'a' => '5'], schedule: 'dummy_task')]
#[AsCronTask(expression: '0 0 * * *', arguments: ['7', 8], schedule: 'dummy_task')]
public function attributesOnMethod(string $a, int $b): void
{
self::$calls[__FUNCTION__][] = [$a, $b];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ public function process(ContainerBuilder $container): void

$taskArguments = [
'$message' => $message,
] + array_filter(match ($tagAttributes['trigger'] ?? throw new InvalidArgumentException("Tag 'scheduler.task' is missing attribute 'trigger' on service $serviceId.")) {
] + array_filter(match ($tagAttributes['trigger'] ?? throw new InvalidArgumentException(sprintf('Tag "scheduler.task" is missing attribute "trigger" on service "%s".', $serviceId))) {
'every' => [
'$frequency' => $tagAttributes['frequency'] ?? throw new InvalidArgumentException("Tag 'scheduler.task' is missing attribute 'frequency' on service $serviceId."),
'$frequency' => $tagAttributes['frequency'] ?? throw new InvalidArgumentException(sprintf('Tag "scheduler.task" is missing attribute "frequency" on service "%s".', $serviceId)),
'$from' => $tagAttributes['from'] ?? null,
'$until' => $tagAttributes['until'] ?? null,
],
'cron' => [
'$expression' => $tagAttributes['expression'] ?? throw new InvalidArgumentException("Tag 'scheduler.task' is missing attribute 'expression' on service $serviceId."),
'$expression' => $tagAttributes['expression'] ?? throw new InvalidArgumentException(sprintf('Tag "scheduler.task" is missing attribute "expression" on service "%s".', $serviceId)),
'$timezone' => $tagAttributes['timezone'] ?? null,
],
}, fn ($value) => null !== $value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ public function testExecuteWithScheduleWithoutTriggerShowingNoNextRunWithAllOpti
"schedule_name\n".
"-------------\n".
"\n".
" --------- ----------------------------------------------------------- ---------- \n".
" Trigger Provider Next Run \n".
" --------- ----------------------------------------------------------- ---------- \n".
" test Symfony\Component\Scheduler\Trigger\StaticMessageProvider - \n".
" --------- ----------------------------------------------------------- ---------- \n".
" --------- ------------------------------- ---------- \n".
" Trigger Provider Next Run \n".
" --------- ------------------------------- ---------- \n".
" test stdClass(O:8:\"stdClass\":0:{}) - \n".
" --------- ------------------------------- ---------- \n".
"\n", $tester->getDisplay(true));
}

Expand Down Expand Up @@ -143,11 +143,11 @@ public function testExecuteWithSchedule()
"schedule_name\n".
"-------------\n".
"\n".
" ------------------------------- ----------------------------------------------------------- --------------------------------- \n".
" Trigger Provider Next Run \n".
" ------------------------------- ----------------------------------------------------------- --------------------------------- \n".
" every first day of next month Symfony\\\\Component\\\\Scheduler\\\\Trigger\\\\StaticMessageProvider \w{3}, \d{1,2} \w{3} \d{4} \d{2}:\d{2}:\d{2} (\+|-)\d{4} \n".
" ------------------------------- ----------------------------------------------------------- --------------------------------- \n".
" ------------------------------- ------------------------------- --------------------------------- \n".
" Trigger Provider Next Run \n".
" ------------------------------- ------------------------------- --------------------------------- \n".
" every first day of next month stdClass\(O:8:\"stdClass\":0:{}\) \w{3}, \d{1,2} \w{3} \d{4} \d{2}:\d{2}:\d{2} (\+|-)\d{4} \n".
" ------------------------------- ------------------------------- --------------------------------- \n".
"\n/", $tester->getDisplay(true));
}
}