From 2a1f5cbad10858da02f0b89edd6face9d8976930 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 28 Jun 2021 13:18:00 +0200 Subject: [PATCH] add test for suggestion household by accompanying period --- .../Controller/HouseholdApiControllerTest.php | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdApiControllerTest.php diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdApiControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdApiControllerTest.php new file mode 100644 index 000000000..f6adc5d01 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdApiControllerTest.php @@ -0,0 +1,55 @@ +getClientAuthenticated(); + + $client->request( + Request::METHOD_GET, + "/api/1.0/person/household/suggest/by-person/{$personId}/through-accompanying-period-participation.json" + ); + + $this->assertResponseIsSuccessful(); + } + + public function generatePersonId() + { + self::bootKernel(); + + $qb = self::$container->get(EntityManagerInterface::class) + ->createQueryBuilder(); + + $period = $qb + ->select('ap') + ->from(AccompanyingPeriod::class, 'ap') + ->where( + $qb->expr()->gte('SIZE(ap.participations)', 2) + ) + ->getQuery() + ->setMaxResults(1) + ->getSingleResult() + ; + + $person = $period->getParticipations() + ->first()->getPerson(); + + yield [ $person->getId() ]; + } +}