mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
test "find household by reference": add exception in data provider
The data provider cannot generate data if no address reference in database. Throw an exception in this case.
This commit is contained in:
parent
9b4c350213
commit
b5a1985fa1
@ -58,10 +58,16 @@ final class HouseholdApiControllerTest extends WebTestCase
|
||||
$centerA = $em->getRepository(Center::class)->findOneBy(['name' => 'Center A']);
|
||||
$nbReference = $em->createQueryBuilder()->select('count(ar)')->from(AddressReference::class, 'ar')
|
||||
->getQuery()->getSingleScalarResult();
|
||||
|
||||
if ($nbReference === 0) {
|
||||
throw new \RuntimeException('any reference found. Add a reference in database to perform this test');
|
||||
}
|
||||
|
||||
$reference = $em->createQueryBuilder()->select('ar')->from(AddressReference::class, 'ar')
|
||||
->setFirstResult(random_int(0, $nbReference))
|
||||
->setMaxResults(1)
|
||||
->getQuery()->getSingleResult();
|
||||
|
||||
$p = new Person();
|
||||
$p->setFirstname('test')->setLastName('test lastname')
|
||||
->setGender(Person::BOTH_GENDER)
|
||||
@ -79,6 +85,7 @@ final class HouseholdApiControllerTest extends WebTestCase
|
||||
[HouseholdMember::class, $m->getId()],
|
||||
[User::class, $p->getId()],
|
||||
[Household::class, $h->getId()],
|
||||
[Person::class, $p->getId()],
|
||||
];
|
||||
|
||||
yield [$reference->getId(), $h->getId()];
|
||||
|
Loading…
x
Reference in New Issue
Block a user