Fix Canceling of stale workflow cronjob

Refactor workflow cancellation logic to encapsulate transition checks in a dedicated method, and update CronJob handling to use entity workflows instead of IDs. Enhance test coverage to ensure proper handling and instantiate mocks for EntityManagerInterface.
This commit is contained in:
2024-10-21 17:39:31 +02:00
parent 1d708a481d
commit 527cf23d4f
6 changed files with 73 additions and 29 deletions

View File

@@ -12,6 +12,7 @@ declare(strict_types=1);
namespace ChillMainBundle\Tests\Repository;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Entity\Workflow\EntityWorkflow;
use Chill\MainBundle\Repository\Workflow\EntityWorkflowRepository;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
@@ -40,9 +41,13 @@ class EntityWorkflowRepositoryTest extends KernelTestCase
{
$repository = new EntityWorkflowRepository($this->em);
$actual = $repository->findWorkflowsWithoutFinalStepAndOlderThan(new \DateTimeImmutable('10 years ago'));
$actual = $repository->findWorkflowsWithoutFinalStepAndOlderThan((new \DateTimeImmutable('now'))->add(new \DateInterval('P10Y')));
self::assertIsArray($actual, 'check that the query is successful');
self::assertIsIterable($actual, 'check that the query is successful');
foreach ($actual as $entityWorkflow) {
self::assertInstanceOf(EntityWorkflow::class, $entityWorkflow);
}
}
public function testCountQueryByDest(): void