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'] ]; + } +}