Fixed: [cron] store the last store of executed tasks correctly

This commit is contained in:
2022-12-27 00:09:45 +01:00
parent 5aa59aa0ff
commit bbd2599e7e
2 changed files with 26 additions and 3 deletions

View File

@@ -44,7 +44,7 @@ final class RefreshAddressToGeographicalUnitMaterializedViewCronJobTest extends
$executedForFirstTime = 0;
$executedAfterPreviousExecution = 0;
for ($round = 0; 20 > $round; ++$round ) {
for ($round = 0; 20 > $round; ++$round) {
if ($job->canRun(null)) {
++$executedForFirstTime;
}
@@ -58,6 +58,28 @@ final class RefreshAddressToGeographicalUnitMaterializedViewCronJobTest extends
$this->assertGreaterThan(0, $executedAfterPreviousExecution);
}
public function testCanRunShouldReturnFalse(): void
{
// As the can run is executed one of ten, this should be executed at least one after
// 10 + 5 executions
$job = new \Chill\MainBundle\Service\AddressGeographicalUnit\RefreshAddressToGeographicalUnitMaterializedViewCronJob(
$this->connection
);
$lastExecution = new CronJobExecution($job->getKey());
$lastExecution->setLastStart(new DateTimeImmutable('2 hours ago'));
$executedAfterPreviousExecution = 0;
for ($round = 0; 20 > $round; ++$round) {
if ($job->canRun($lastExecution)) {
++$executedAfterPreviousExecution;
}
}
$this->assertEquals(0, $executedAfterPreviousExecution);
}
public function testFullRun(): void
{
$job = new \Chill\MainBundle\Service\AddressGeographicalUnit\RefreshAddressToGeographicalUnitMaterializedViewCronJob(