Feature: [cron] Create a cron job to refresh materialized view address - geographical unit association

This commit is contained in:
2022-12-12 14:35:18 +01:00
parent 4fcfe3f5d2
commit e0c9e12008
3 changed files with 108 additions and 7 deletions

View File

@@ -0,0 +1,46 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\MainBundle\Tests\Services\AddressGeographicalUnit;
use Chill\MainBundle\Entity\CronJobExecution;
use DateTimeImmutable;
use Doctrine\DBAL\Connection;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
/**
* @internal
* @coversNothing
*/
final class RefreshAddressToGeographicalUnitMaterializedViewCronJobTest extends KernelTestCase
{
private Connection $connection;
protected function setUp(): void
{
parent::bootKernel();
$this->connection = self::$container->get(Connection::class);
}
public function testFullRun(): void
{
$job = new \Chill\MainBundle\Service\AddressGeographicalUnit\RefreshAddressToGeographicalUnitMaterializedViewCronJob(
$this->connection
);
$lastExecution = new CronJobExecution($job->getKey());
$lastExecution->setLastStart(new DateTimeImmutable('2 days ago'));
$this->assertIsBool($job->canRun($lastExecution));
$job->run();
}
}