mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2026-04-10 06:53:45 +00:00
Fix bugs in api endpoint to filter tickets, and add parameters byAddresseeGroup and byCreator
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user