mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-28 13:06:13 +00:00
Add null check to canRun method in CancelStaleWorkflowCronJob
Ensure the canRun method in CancelStaleWorkflowCronJob returns true when the cron job execution is null. This change includes updating the corresponding test case to cover the new behavior.
This commit is contained in:
parent
4dc2348893
commit
5c0a383909
@ -37,6 +37,10 @@ class CancelStaleWorkflowCronJob implements CronJobInterface
|
|||||||
|
|
||||||
public function canRun(?CronJobExecution $cronJobExecution): bool
|
public function canRun(?CronJobExecution $cronJobExecution): bool
|
||||||
{
|
{
|
||||||
|
if (null === $cronJobExecution) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return $this->clock->now() >= $cronJobExecution->getLastEnd()->add(new \DateInterval('P1D'));
|
return $this->clock->now() >= $cronJobExecution->getLastEnd()->add(new \DateInterval('P1D'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,6 +104,11 @@ class CancelStaleWorkflowCronJobTest extends TestCase
|
|||||||
(new CronJobExecution('last-canceled-workflow-id'))->setLastEnd(new \DateTimeImmutable('2023-12-31 00:00:01', new \DateTimeZone('+00:00'))),
|
(new CronJobExecution('last-canceled-workflow-id'))->setLastEnd(new \DateTimeImmutable('2023-12-31 00:00:01', new \DateTimeZone('+00:00'))),
|
||||||
false,
|
false,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
yield [
|
||||||
|
null,
|
||||||
|
true
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
private function buildMessageBus(bool $expectDispatchAtLeastOnce = false): MessageBusInterface
|
private function buildMessageBus(bool $expectDispatchAtLeastOnce = false): MessageBusInterface
|
||||||
|
Loading…
x
Reference in New Issue
Block a user