From 0158c6f2ed7584b49eec58ad5ef337d87e46ac74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 2 Jun 2021 16:21:01 +0200 Subject: [PATCH] add tests for household --- .../Controller/HouseholdControllerTest.php | 97 +++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdControllerTest.php diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdControllerTest.php new file mode 100644 index 000000000..33e930e23 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdControllerTest.php @@ -0,0 +1,97 @@ +client = $this->getClientAuthenticated(); + } + + /** + * @dataProvider generateValidHouseholdIds + */ + public function testSummary($householdId) + { + $this->client->request( + Request::METHOD_GET, + "/fr/person/household/{$householdId}/summary" + ); + + $this->assertResponseIsSuccessful(); + } + + /** + * @dataProvider generateValidHouseholdIds + */ + public function testMembers($householdId) + { + $this->client->request( + Request::METHOD_GET, + "/fr/person/household/{$householdId}/members" + ); + + $this->assertResponseIsSuccessful(); + } + + /** + * @dataProvider generateValidHouseholdIds + */ + public function testAddresses($householdId) + { + $this->client->request( + Request::METHOD_GET, + "/fr/person/household/{$householdId}/addresses" + ); + + $this->assertResponseIsSuccessful(); + } + + /** + * @dataProvider generateValidHouseholdIds + */ + public function testAddressMove($householdId) + { + $this->client->request( + Request::METHOD_GET, + "/fr/person/household/{$householdId}/address/move" + ); + + $this->assertResponseIsSuccessful(); + + // ici, il faudrait tester la requĂȘte POST + } + + public function generateValidHouseholdIds() + { + self::bootKernel(); + $em = self::$container->get(EntityManagerInterface::class); + + $ids = $em->createQuery("SELECT DISTINCT h.id FROM ".Household::class." h ". + "JOIN h.members m ". + "JOIN m.person p ". + "JOIN p.center c ". + "WHERE c.name = :center" + ) + ->setParameter('center', "Center A") + ->setMaxResults(100) + ->getScalarResult() + ; + + \shuffle($ids); + + yield [ \array_pop($ids)['id'] ]; + } +}