Ticket: ajout de paramètres à la requête de liste de tickets

This commit is contained in:
2025-07-16 13:39:27 +00:00
parent bbf387d96f
commit faed443a96
15 changed files with 1441 additions and 99 deletions

View File

@@ -12,6 +12,8 @@ declare(strict_types=1);
namespace Chill\TicketBundle\Tests\Repository;
use Chill\PersonBundle\DataFixtures\Helper\RandomPersonHelperTrait;
use Chill\TicketBundle\Entity\EmergencyStatusEnum;
use Chill\TicketBundle\Entity\Motive;
use Chill\TicketBundle\Entity\StateEnum;
use Chill\TicketBundle\Repository\TicketACLAwareRepository;
use Doctrine\ORM\EntityManagerInterface;
@@ -74,8 +76,51 @@ class TicketACLAwareRepositoryTest extends KernelTestCase
public function testFindTicketByCurrentStateMultipleState(): void
{
$result = $this->repository->countTickets(['byCurrentState' => [StateEnum::OPEN, StateEnum::CLOSED]]);
$result = $this->repository->findTickets(['byCurrentState' => [StateEnum::OPEN, StateEnum::CLOSED]]);
self::assertIsArray($result);
}
public function testCountTicketByCurrentStateEmergencySingleState(): void
{
$result = $this->repository->countTickets(['byCurrentStateEmergency' => [EmergencyStatusEnum::YES]]);
self::assertIsInt($result);
}
public function testFindTicketByCurrentStateEmergencyMultipleState(): void
{
$result = $this->repository->findTickets(['byCurrentStateEmergency' => [EmergencyStatusEnum::YES, EmergencyStatusEnum::NO]]);
self::assertIsArray($result);
}
public function testFindTicketByMotives(): void
{
$motives = $this->entityManager->createQuery(sprintf('SELECT m FROM %s m', Motive::class))
->setMaxResults(2)
->getResult();
if ([] === $motives) {
throw new \UnexpectedValueException('No motives found');
}
$results = $this->repository->findTickets(['byMotives' => $motives]);
self::assertIsArray($results);
}
public function testFindTicketByCreatedBefore(): void
{
$actual = $this->repository->findTickets(['byCreatedBefore' => (new \DateTimeImmutable('now'))->add(new \DateInterval('P1D'))]);
self::assertIsArray($actual);
}
public function testFindTicketByCreatedAfter(): void
{
$actual = $this->repository->findTickets(['byCreatedAfter' => (new \DateTimeImmutable('now'))->sub(new \DateInterval('P1M'))]);
self::assertIsArray($actual);
}
}