client = self::createClient([], [ 'PHP_AUTH_USER' => 'center a_social', 'PHP_AUTH_PW' => 'password', ]); } public function provideAccompanyingPeriod(): iterable { self::bootKernel(); $em = self::$container->get(EntityManagerInterface::class); $nb = $em->createQueryBuilder() ->from(AccompanyingPeriod::class, 'ac') ->select('COUNT(ac) AS nb') ->getQuery() ->getSingleScalarResult(); yield [$em->createQueryBuilder() ->from(AccompanyingPeriod::class, 'ac') ->select('ac.id') ->setFirstResult(random_int(0, $nb)) ->setMaxResults(1) ->getQuery() ->getSingleScalarResult(), ]; } /** * @dataProvider provideAccompanyingPeriod */ public function testList(int $accompanyingPeriodId) { $this->client->request( Request::METHOD_GET, sprintf('/fr/calendar/calendar/?accompanying_period_id=%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()); } }