From abc067adae0f1659c8fc11f92684112b3da3c10e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 28 Jul 2023 00:51:44 +0200 Subject: [PATCH] More useful error message when not enough people in database fixture --- ...companyingPeriodACLAwareRepositoryTest.php | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Tests/Repository/AccompanyingPeriodACLAwareRepositoryTest.php b/src/Bundle/ChillPersonBundle/Tests/Repository/AccompanyingPeriodACLAwareRepositoryTest.php index 9e2bf622f..032bce7e7 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Repository/AccompanyingPeriodACLAwareRepositoryTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Repository/AccompanyingPeriodACLAwareRepositoryTest.php @@ -139,16 +139,18 @@ class AccompanyingPeriodACLAwareRepositoryTest extends KernelTestCase throw new \RuntimeException("no user found"); } - /** @var Person $person */ - [$person, $anotherPerson, $person2, $person3] = $this->entityManager + $persons = $this->entityManager ->createQuery("SELECT p FROM " . Person::class . " p JOIN p.centerCurrent current_center") ->setMaxResults(4) ->getResult(); - if (null === $person || null === $anotherPerson || null === $person2 || null === $person3) { + if (4 > count($persons)) { throw new \RuntimeException("no person found"); } + /** @var Person $person */ + [$person, $anotherPerson, $person2, $person3] = $persons; + $scopes = $this->scopeRepository->findAll(); if (3 > count($scopes)) { @@ -311,15 +313,17 @@ class AccompanyingPeriodACLAwareRepositoryTest extends KernelTestCase } /** @var Person $person */ - [$person, $anotherPerson, $person2, $person3] = $this->entityManager + $persons = $this->entityManager ->createQuery("SELECT p FROM " . Person::class . " p ") ->setMaxResults(4) ->getResult(); - if (null === $person || null === $anotherPerson || null === $person2 || null === $person3) { + if (4 > count($persons)) { throw new \RuntimeException("no person found"); } + [$person, $anotherPerson, $person2, $person3] = $persons; + $scopes = $this->scopeRepository->findAll(); if (3 > count($scopes)) { @@ -439,15 +443,17 @@ class AccompanyingPeriodACLAwareRepositoryTest extends KernelTestCase throw new \RuntimeException("no user found"); } - [$person, $anotherPerson, $person2, $person3] = $this->entityManager + $persons = $this->entityManager ->createQuery("SELECT p FROM " . Person::class . " p WHERE SIZE(p.accompanyingPeriodParticipations) = 0") ->setMaxResults(4) ->getResult(); - if (null === $person || null === $anotherPerson || null === $person2 || null === $person3) { + if (4 > count($persons)) { throw new \RuntimeException("no person found"); } + [$person, $anotherPerson, $person2, $person3] = $persons; + $scopes = $this->scopeRepository->findAll(); if (3 > count($scopes)) {