client = $this->getClientAuthenticated(); } protected function tearDown(): void { self::ensureKernelShutdown(); } public static function provideAccompanyingPeriod(): iterable { self::bootKernel(); $em = self::getContainer()->get(EntityManagerInterface::class); $nb = $em->createQueryBuilder() ->from(AccompanyingPeriod::class, 'ac') ->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') ->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(), ]; self::ensureKernelShutdown(); } /** * @dataProvider provideAccompanyingPeriod */ public function testList(int $accompanyingPeriodId) { $this->client->request( Request::METHOD_GET, sprintf('/fr/calendar/calendar/by-period/%d', $accompanyingPeriodId) ); $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); } /** * @dataProvider provideAccompanyingPeriod */ public function testNew(int $accompanyingPeriodId) { $this->client->request( Request::METHOD_GET, sprintf('/fr/calendar/calendar/new?accompanying_period_id=%d', $accompanyingPeriodId) ); $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); } }