mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-30 02:25:00 +00:00
Use Person::centerHistory
to load fixtures with given center
This commit is contained in:
@@ -43,13 +43,14 @@ final class HouseholdMemberControllerTest extends WebTestCase
|
||||
self::bootKernel();
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
$membershipIds = $em->createQuery('SELECT m.id FROM ' . HouseholdMember::class . ' m ' .
|
||||
'JOIN m.person p ' .
|
||||
'JOIN p.center c ' .
|
||||
'WHERE c.name = :center AND m.endDate IS NULL')
|
||||
$membershipIds = $em->createQuery(sprintf("SELECT m.id FROM %s m JOIN m.person p JOIN p.centerHistory ch JOIN ch.center c WHERE c.name = :center AND m.endDate IS NULL AND ch.endDate IS NULL", HouseholdMember::class))
|
||||
->setParameter('center', 'Center A')
|
||||
->getScalarResult();
|
||||
|
||||
if ([] === $membershipIds) {
|
||||
throw new \RuntimeException("no memberships for person associated to 'Center A'");
|
||||
}
|
||||
|
||||
shuffle($membershipIds);
|
||||
|
||||
yield [array_pop($membershipIds)['id']];
|
||||
@@ -62,15 +63,16 @@ final class HouseholdMemberControllerTest extends WebTestCase
|
||||
$yesterday = new DateTimeImmutable('yesterday');
|
||||
|
||||
$personIds = $em->createQuery(
|
||||
'SELECT p.id FROM ' . Person::class . ' p ' .
|
||||
'JOIN p.center c ' .
|
||||
'WHERE ' .
|
||||
'c.name = :center '
|
||||
sprintf("SELECT p.id FROM %s p JOIN p.centerHistory ch JOIN ch.center c WHERE c.name = :center AND ch.endDate IS NULL", Person::class)
|
||||
)
|
||||
->setParameter('center', 'Center A')
|
||||
->setMaxResults(100)
|
||||
->getScalarResult();
|
||||
|
||||
if ([] === $personIds) {
|
||||
throw new \RuntimeException('no person associated with "Center A"');
|
||||
}
|
||||
|
||||
shuffle($personIds);
|
||||
|
||||
$household = new Household();
|
||||
@@ -111,7 +113,7 @@ final class HouseholdMemberControllerTest extends WebTestCase
|
||||
/**
|
||||
* @dataProvider provideValidDataEditMember
|
||||
*/
|
||||
public function testEditMember(mixed $memberId)
|
||||
public function testEditMember(int $memberId)
|
||||
{
|
||||
$client = $this->getClientAuthenticated();
|
||||
|
||||
|
Reference in New Issue
Block a user