Use Person::centerHistory to load fixtures with given center

This commit is contained in:
2023-07-28 01:22:55 +02:00
parent 0e94e769cb
commit 6f2b538e27
5 changed files with 28 additions and 21 deletions

View File

@@ -43,16 +43,16 @@ final class HouseholdControllerTest extends WebTestCase
$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'
sprintf("SELECT DISTINCT h.id FROM %s h JOIN h.members m JOIN m.person p JOIN p.centerHistory ch JOIN ch.center c WHERE c.name = :center AND ch.endDate IS NULL", Household::class)
)
->setParameter('center', 'Center A')
->setMaxResults(100)
->getScalarResult();
if ([] === $ids) {
throw new \RuntimeException('no household ids with center "Center A"');
}
shuffle($ids);
yield [array_pop($ids)['id']];