Fix bugs in api endpoint to filter tickets, and add parameters byAddresseeGroup and byCreator

This commit is contained in:
2025-09-08 14:18:02 +00:00
committed by GitLab
parent 807f2711fe
commit 18f67801c7
17 changed files with 611 additions and 38 deletions

View File

@@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\TicketBundle\Tests\Repository;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Entity\UserGroup;
use Chill\PersonBundle\DataFixtures\Helper\RandomPersonHelperTrait;
use Chill\TicketBundle\Entity\EmergencyStatusEnum;
use Chill\TicketBundle\Entity\Motive;
@@ -139,4 +140,49 @@ class TicketACLAwareRepositoryTest extends KernelTestCase
self::assertIsArray($actual);
}
public function testFindByCreator(): void
{
$users = $this->entityManager->createQuery('SELECT u FROM '.User::class.' u')
->setMaxResults(2)
->getResult();
if ([] === $users) {
throw new \UnexpectedValueException('No users found');
}
$actual = $this->repository->findTickets(['byCreator' => $users]);
self::assertIsArray($actual);
}
public function testCountByCreator(): void
{
$users = $this->entityManager->createQuery('SELECT u FROM '.User::class.' u')
->setMaxResults(2)
->getResult();
if ([] === $users) {
throw new \UnexpectedValueException('No users found');
}
$count = $this->repository->countTickets(['byCreator' => $users]);
self::assertIsInt($count);
}
public function testFindByAddresseeGroup(): void
{
$userGroups = $this->entityManager->createQuery('SELECT ug FROM '.UserGroup::class.' ug')
->setMaxResults(2)
->getResult();
if ([] === $userGroups) {
throw new \UnexpectedValueException('No users found');
}
$actual = $this->repository->findTickets(['byCreator' => $userGroups]);
self::assertIsArray($actual);
}
}