Fix calendarControllerTest: fix acl, and add calendar acl on fixtures

This commit is contained in:
2023-08-25 23:09:46 +02:00
parent 410aa7098a
commit ea9c21e021
3 changed files with 85 additions and 14 deletions

View File

@@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\CalendarBundle\Tests\Controller;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\HttpFoundation\Request;
@@ -42,14 +43,32 @@ final class CalendarControllerTest extends WebTestCase
$nb = $em->createQueryBuilder()
->from(AccompanyingPeriod::class, 'ac')
->select('COUNT(ac) AS nb')
->join('ac.participations', 'acp')
->join('acp.person', 'person')
->join('person.centerCurrent', 'pc')
->join('pc.center', 'center')
->where('center.name LIKE :n')
->setParameter('n', 'Center A')
->join('ac.scopes', 's')
->andWhere('JSON_EXTRACT(s.name,\'fr\') LIKE :s')
->setParameter('s', 'social')
->select('COUNT(DISTINCT ac) AS nb')
->getQuery()
->getSingleScalarResult();
yield [$em->createQueryBuilder()
->from(AccompanyingPeriod::class, 'ac')
->select('ac.id')
->setFirstResult(random_int(0, $nb))
->join('ac.participations', 'acp')
->join('acp.person', 'person')
->join('person.centerCurrent', 'pc')
->join('pc.center', 'center')
->where('center.name LIKE :n')
->setParameter('n', 'Center A')
->join('ac.scopes', 's')
->andWhere('JSON_EXTRACT(s.name,\'fr\') LIKE :s')
->setParameter('s', 'social')
->setFirstResult(random_int(0, $nb - 1))
->setMaxResults(1)
->getQuery()
->getSingleScalarResult(),
@@ -63,7 +82,7 @@ final class CalendarControllerTest extends WebTestCase
{
$this->client->request(
Request::METHOD_GET,
sprintf('/fr/calendar/calendar/?accompanying_period_id=%d', $accompanyingPeriodId)
sprintf('/fr/calendar/calendar/by-period/%d', $accompanyingPeriodId)
);
$this->assertEquals(200, $this->client->getResponse()->getStatusCode());