From a78f29cffc1e940caeeab6a294d48b752d84e292 Mon Sep 17 00:00:00 2001 From: nobohan Date: Tue, 1 Feb 2022 17:44:55 +0100 Subject: [PATCH 1/6] on the fly component: add returnPath when viewing --- .../public/vuejs/OnTheFly/components/OnTheFly.vue | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue index 116ed86c1..c3522863c 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue @@ -160,7 +160,10 @@ export default { }, badgeType() { return 'entity-' + this.type + ' badge-' + this.type; - } + }, + getReturnPath() { + return `?returnPath=${window.location.pathname}${window.location.search}${window.location.hash}`; + }, }, watch: { canCloseModal: { @@ -217,9 +220,9 @@ export default { buildLocation(id, type) { if (type === 'person') { // TODO i18n - return `/fr/person/${id}/general`; + return encodeURI(`/fr/person/${id}/general${this.getReturnPath}`); } else if (type === 'thirdparty') { - return `/fr/3party/3party/${id}/view`; + return encodeURI(`/fr/3party/3party/${id}/view${this.getReturnPath}`); } } } From a83b0326d762d71142bdeb37b9f701a2f8d9a7a7 Mon Sep 17 00:00:00 2001 From: nobohan Date: Wed, 2 Feb 2022 07:04:14 +0100 Subject: [PATCH 2/6] upd CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a198c0929..e7ca8f3ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to ## Unreleased +* [person] add a returnPath when clicking on some Person or ThirdParty badge (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/427) * renommer "dossier numéro" en "parcours numéro" dans les résultats de recherche * renomme date de début en date d'ouverture dans le formulaire parcours From 9ba0cb0c2a0575ea4573deb24701c78aaceb4406 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Fri, 11 Feb 2022 12:56:15 +0100 Subject: [PATCH 3/6] homepage_widget: fix translation for emergency badge --- .../public/vuejs/HomepageWidget/MyAccompanyingCourses.vue | 6 ++++-- .../Resources/public/vuejs/HomepageWidget/js/i18n.js | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/HomepageWidget/MyAccompanyingCourses.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/HomepageWidget/MyAccompanyingCourses.vue index 4292c3af5..1c3b5e152 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/HomepageWidget/MyAccompanyingCourses.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/HomepageWidget/MyAccompanyingCourses.vue @@ -32,7 +32,7 @@ - {{ $t('emergency') }} + {{ $t('emergency') }} {{ $t('confidential') }} @@ -80,5 +80,7 @@ export default { \ No newline at end of file diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/HomepageWidget/js/i18n.js b/src/Bundle/ChillMainBundle/Resources/public/vuejs/HomepageWidget/js/i18n.js index 0b3d6a428..29f9dac62 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/HomepageWidget/js/i18n.js +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/HomepageWidget/js/i18n.js @@ -50,7 +50,9 @@ const appMessages = { assignated_evaluations: "{n} évaluation assignée | {n} évaluations assignées", alert_tasks: "{n} tâche en rappel | {n} tâches en rappel", warning_tasks: "{n} tâche à échéance | {n} tâches à échéance", - } + }, + emergency: "Urgent", + confidential: "Confidentiel", } }; From 13eddbfc5b6930f50c5897642310d941e3209cec Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Fri, 11 Feb 2022 13:16:48 +0100 Subject: [PATCH 4/6] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 84dc079a3..94195dbd1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to * change order for accompanying course work list * [person]: style fix in parcours listing per person. (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/432) * [pick entity]: fix translations in modal (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/419) +* [homepage_widget]: fix translation on emergency badge (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/440) ## Test releases From a9624b36f764dc5e35db3058ffa4e0e8c5795d98 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 11 Feb 2022 14:16:46 +0100 Subject: [PATCH 5/6] create person and household option added to dropdown --- CHANGELOG.md | 1 + .../ChillPersonBundle/Controller/PersonController.php | 8 ++++++++ .../Resources/views/Person/create.html.twig | 3 +++ src/Bundle/ChillPersonBundle/translations/messages.fr.yml | 2 +- 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 92e765829..ed13389fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ and this project adheres to * ajoute un ordre dans les localisation (api) * [pick entity]: fix translations in modal (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/419) * [homepage_widget]: fix translation on emergency badge (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/440) +* [person]: create person and household added to button dropdown (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/454) ## Test releases diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonController.php b/src/Bundle/ChillPersonBundle/Controller/PersonController.php index 02c77ebd3..ac371a2af 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonController.php @@ -224,6 +224,8 @@ final class PersonController extends AbstractController 'label' => 'Add the person', ])->add('createPeriod', SubmitType::class, [ 'label' => 'Add the person and create an accompanying period', + ])->add('createHousehold', SubmitType::class, [ + 'label' => 'Add the person and create a household' ]); $form->handleRequest($request); @@ -252,6 +254,12 @@ final class PersonController extends AbstractController ]); } + if ($form->get('createHousehold')->isClicked()) { + return $this->redirectToRoute('chill_person_household_members_editor', [ + 'persons' => [$person->getId()], + ]); + } + return $this->redirectToRoute( 'chill_person_general_edit', ['person_id' => $person->getId()] diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Person/create.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Person/create.html.twig index 70d6a4a8e..3a9083310 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Person/create.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Person/create.html.twig @@ -115,6 +115,9 @@
  • {{ form_widget(form.editPerson, { 'attr': { 'class': 'dropdown-item' }}) }}
  • +
  • + {{ form_widget(form.createHousehold, { 'attr': { 'class': 'dropdown-item' }}) }} +
  • {{ form_widget(form.createPeriod, { 'attr': { 'class': 'dropdown-item' }}) }}
  • diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 91aed0304..60cf842af 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -124,7 +124,7 @@ address_country_code: Code pays 'Alreay existing person': 'Dossiers déjà encodés' 'Add the person': 'Ajouter la personne' 'Add the person and create an accompanying period': "Créer la personne & créer une période d'accompagnement" -'Add the person and create an household': "Créer la personne & créer un ménage" +'Add the person and create a household': "Créer la personne & créer un ménage" Show person: Voir le dossier de la personne 'Confirm the creation': 'Confirmer la création' 'You will create this person': 'Vous allez créer le dossier suivant' From 657bf7075b3cb4cf63a5c5dbd90ee6b8a0ebfff4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 11 Feb 2022 13:18:32 +0000 Subject: [PATCH 6/6] fix ci --- phpstan-deprecations.neon | 9 ------ .../Controller/WorkflowController.php | 3 +- .../Entity/Workflow/EntityWorkflow.php | 29 ++++++++----------- .../Workflow/EntityWorkflowStepRepository.php | 2 +- .../Entity/Workflow/EntityWorkflowTest.php | 19 +++++------- .../Counter/WorkflowByUserCounter.php | 8 ++--- .../Workflow/Helper/MetadataExtractor.php | 17 ++++++----- .../Controller/HouseholdApiController.php | 1 - .../Entity/AccompanyingPeriod.php | 7 ++--- .../Household/HouseholdACLAwareRepository.php | 4 +-- .../Normalizer/PersonJsonNormalizer.php | 2 +- .../Controller/HouseholdApiControllerTest.php | 8 +++++ .../Tests/Entity/AccompanyingPeriodTest.php | 21 +++++++++----- 13 files changed, 63 insertions(+), 67 deletions(-) diff --git a/phpstan-deprecations.neon b/phpstan-deprecations.neon index bc372e96b..b41a746b9 100644 --- a/phpstan-deprecations.neon +++ b/phpstan-deprecations.neon @@ -927,15 +927,6 @@ parameters: count: 1 path: src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php - - - message: - """ - #^Parameter \\$trans of method Chill\\\\PersonBundle\\\\Controller\\\\AccompanyingCourseWorkController\\:\\:__construct\\(\\) has typehint with deprecated interface Symfony\\\\Component\\\\Translation\\\\TranslatorInterface\\: - since Symfony 4\\.2, use Symfony\\\\Contracts\\\\Translation\\\\TranslatorInterface instead$# - """ - count: 1 - path: src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php - - message: """ diff --git a/src/Bundle/ChillMainBundle/Controller/WorkflowController.php b/src/Bundle/ChillMainBundle/Controller/WorkflowController.php index 247cdf552..876e095a8 100644 --- a/src/Bundle/ChillMainBundle/Controller/WorkflowController.php +++ b/src/Bundle/ChillMainBundle/Controller/WorkflowController.php @@ -167,6 +167,7 @@ class WorkflowController extends AbstractController $handler = $this->entityWorkflowManager->getHandler($entityWorkflow); $workflow = $this->registry->get($entityWorkflow, $entityWorkflow->getWorkflowName()); + $errors = []; if (count($workflow->getEnabledTransitions($entityWorkflow)) > 0) { // possible transition @@ -245,7 +246,7 @@ class WorkflowController extends AbstractController 'handler_template_data' => $handler->getTemplateData($entityWorkflow), 'transition_form' => isset($transitionForm) ? $transitionForm->createView() : null, 'entity_workflow' => $entityWorkflow, - 'transition_form_errors' => $errors ?? [], + 'transition_form_errors' => $errors, //'comment_form' => $commentForm->createView(), ] ); diff --git a/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflow.php b/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflow.php index a132706d7..b9773040a 100644 --- a/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflow.php +++ b/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflow.php @@ -135,6 +135,7 @@ class EntityWorkflow implements TrackCreationInterface, TrackUpdateInterface if (!$this->steps->contains($step)) { $this->steps[] = $step; $step->setEntityWorkflow($this); + $this->stepsChainedCache = null; } return $this; @@ -332,32 +333,26 @@ class EntityWorkflow implements TrackCreationInterface, TrackUpdateInterface public function isFinal(): bool { - $steps = $this->getStepsChained(); - - if (1 === count($steps)) { - // the initial step cannot be finalized - return false; + foreach ($this->getStepsChained() as $step) { + if ($step->isFinal()) { + return true; + } } - /** @var EntityWorkflowStep $last */ - $last = end($steps); - - return $last->isFinal(); + return false; } public function isFreeze(): bool { $steps = $this->getStepsChained(); - if (1 === count($steps)) { - // the initial step cannot be finalized - return false; + foreach ($this->getStepsChained() as $step) { + if ($step->isFreezeAfter()) { + return true; + } } - /** @var EntityWorkflowStep $last */ - $last = end($steps); - - return $last->getPrevious()->isFreezeAfter(); + return false; } public function isUserSubscribedToFinal(User $user): bool @@ -434,7 +429,7 @@ class EntityWorkflow implements TrackCreationInterface, TrackUpdateInterface $newStep->setCurrentStep($step); // copy the freeze - if ($this->getCurrentStep()->isFreezeAfter()) { + if ($this->isFreeze()) { $newStep->setFreezeAfter(true); } diff --git a/src/Bundle/ChillMainBundle/Repository/Workflow/EntityWorkflowStepRepository.php b/src/Bundle/ChillMainBundle/Repository/Workflow/EntityWorkflowStepRepository.php index ad1b21c79..e4f0aa45d 100644 --- a/src/Bundle/ChillMainBundle/Repository/Workflow/EntityWorkflowStepRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/Workflow/EntityWorkflowStepRepository.php @@ -56,7 +56,7 @@ class EntityWorkflowStepRepository implements ObjectRepository public function getClassName() { - return EntityWorkflow::class; + return EntityWorkflowStep::class; } private function buildQueryByUser(User $user): QueryBuilder diff --git a/src/Bundle/ChillMainBundle/Tests/Entity/Workflow/EntityWorkflowTest.php b/src/Bundle/ChillMainBundle/Tests/Entity/Workflow/EntityWorkflowTest.php index c89101c5b..91783a77b 100644 --- a/src/Bundle/ChillMainBundle/Tests/Entity/Workflow/EntityWorkflowTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Entity/Workflow/EntityWorkflowTest.php @@ -24,30 +24,30 @@ final class EntityWorkflowTest extends TestCase { $entityWorkflow = new EntityWorkflow(); - $entityWorkflow->getCurrentStep()->setFinalizeAfter(true); $entityWorkflow->setStep('final'); + $entityWorkflow->getCurrentStep()->setIsFinal(true); - $this->assertTrue($entityWorkflow->isFinalize()); + $this->assertTrue($entityWorkflow->isFinal()); } public function testIsFinalizeWith4Steps() { $entityWorkflow = new EntityWorkflow(); - $this->assertFalse($entityWorkflow->isFinalize()); + $this->assertFalse($entityWorkflow->isFinal()); $entityWorkflow->setStep('two'); - $this->assertFalse($entityWorkflow->isFinalize()); + $this->assertFalse($entityWorkflow->isFinal()); $entityWorkflow->setStep('previous_final'); - $this->assertFalse($entityWorkflow->isFinalize()); + $this->assertFalse($entityWorkflow->isFinal()); - $entityWorkflow->getCurrentStep()->setFinalizeAfter(true); + $entityWorkflow->getCurrentStep()->setIsFinal(true); $entityWorkflow->setStep('final'); - $this->assertTrue($entityWorkflow->isFinalize()); + $this->assertTrue($entityWorkflow->isFinal()); } public function testIsFreeze() @@ -64,11 +64,8 @@ final class EntityWorkflowTest extends TestCase $this->assertFalse($entityWorkflow->isFreeze()); - $entityWorkflow->getCurrentStep()->setFreezeAfter(true); - - $this->assertFalse($entityWorkflow->isFreeze()); - $entityWorkflow->setStep('freezed'); + $entityWorkflow->getCurrentStep()->setFreezeAfter(true); $this->assertTrue($entityWorkflow->isFreeze()); diff --git a/src/Bundle/ChillMainBundle/Workflow/Counter/WorkflowByUserCounter.php b/src/Bundle/ChillMainBundle/Workflow/Counter/WorkflowByUserCounter.php index 41ffd63c2..aaac6b216 100644 --- a/src/Bundle/ChillMainBundle/Workflow/Counter/WorkflowByUserCounter.php +++ b/src/Bundle/ChillMainBundle/Workflow/Counter/WorkflowByUserCounter.php @@ -32,20 +32,20 @@ final class WorkflowByUserCounter implements NotificationCounterInterface, Event $this->cacheItemPool = $cacheItemPool; } - public function addNotification(UserInterface $user): int + public function addNotification(UserInterface $u): int { - if (!$user instanceof User) { + if (!$u instanceof User) { return 0; } - $key = self::generateCacheKeyWorkflowByUser($user); + $key = self::generateCacheKeyWorkflowByUser($u); $item = $this->cacheItemPool->getItem($key); if ($item->isHit()) { return $item->get(); } - $nb = $this->getCountUnreadByUser($user); + $nb = $this->getCountUnreadByUser($u); $item->set($nb) ->expiresAfter(60 * 15); diff --git a/src/Bundle/ChillMainBundle/Workflow/Helper/MetadataExtractor.php b/src/Bundle/ChillMainBundle/Workflow/Helper/MetadataExtractor.php index 60b65020e..32f78a548 100644 --- a/src/Bundle/ChillMainBundle/Workflow/Helper/MetadataExtractor.php +++ b/src/Bundle/ChillMainBundle/Workflow/Helper/MetadataExtractor.php @@ -72,17 +72,18 @@ class MetadataExtractor foreach ($transitions as $transition) { if ($transition->getName() === $transitionName) { - break; + $metadata = $workflow->getMetadataStore()->getTransitionMetadata($transition); + + return [ + 'name' => $transition->getName(), + 'text' => array_key_exists('label', $metadata) ? + $this->translatableStringHelper->localize($metadata['label']) : $transition->getName(), + 'isForward' => $metadata['isForward'] ?? null, + ]; } } - $metadata = $workflow->getMetadataStore()->getTransitionMetadata($transition); - return [ - 'name' => $transition->getName(), - 'text' => array_key_exists('label', $metadata) ? - $this->translatableStringHelper->localize($metadata['label']) : $transition->getName(), - 'isForward' => $metadata['isForward'] ?? null, - ]; + return []; } public function buildArrayPresentationForWorkflow(WorkflowInterface $workflow): array diff --git a/src/Bundle/ChillPersonBundle/Controller/HouseholdApiController.php b/src/Bundle/ChillPersonBundle/Controller/HouseholdApiController.php index da8655f3d..1ebde2b57 100644 --- a/src/Bundle/ChillPersonBundle/Controller/HouseholdApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/HouseholdApiController.php @@ -50,7 +50,6 @@ class HouseholdApiController extends ApiController */ public function getHouseholdByAddressReference(AddressReference $addressReference): Response { - // TODO ACL $this->denyAccessUnlessGranted('ROLE_USER'); $total = $this->householdACLAwareRepository->countByAddressReference($addressReference); diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php index 593cdfc83..1e7444af6 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php @@ -1153,11 +1153,8 @@ class AccompanyingPeriod implements $this->removeComment($this->pinnedComment); } - if ($comment instanceof Comment) { - if (null !== $this->pinnedComment) { - $this->addComment($this->pinnedComment); - } - $this->addComment($comment); + if (null !== $this->pinnedComment) { + $this->addComment($this->pinnedComment); } $this->pinnedComment = $comment; diff --git a/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdACLAwareRepository.php b/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdACLAwareRepository.php index dc5e8f5d3..48dabd054 100644 --- a/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdACLAwareRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdACLAwareRepository.php @@ -14,7 +14,7 @@ namespace Chill\PersonBundle\Repository\Household; use Chill\MainBundle\Entity\AddressReference; use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Chill\PersonBundle\Entity\Household\Household; -use Chill\PersonBundle\Security\Authorization\HouseholdVoter; +use Chill\PersonBundle\Security\Authorization\PersonVoter; use DateTime; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\QueryBuilder; @@ -39,7 +39,7 @@ final class HouseholdACLAwareRepository implements HouseholdACLAwareRepositoryIn { $centers = $this->authorizationHelper->getReachableCenters( $this->security->getUser(), - HouseholdVoter::SEE + PersonVoter::SEE // the authorization to see a household is the same as seeing a person ); if ([] === $centers) { diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php index bfac5f936..e91748de8 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php @@ -91,7 +91,7 @@ class PersonJsonNormalizer implements 'deathdate', 'center', 'altNames', - 'email' + 'email', ]; $fields = array_filter( diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdApiControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdApiControllerTest.php index 419179077..08034978e 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdApiControllerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdApiControllerTest.php @@ -21,6 +21,7 @@ use Chill\PersonBundle\Entity\Household\HouseholdMember; use Chill\PersonBundle\Entity\Person; use DateTime; use Doctrine\ORM\EntityManagerInterface; +use RuntimeException; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Component\HttpFoundation\Request; use function array_map; @@ -58,10 +59,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 (0 === $nbReference) { + 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 +86,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()]; diff --git a/src/Bundle/ChillPersonBundle/Tests/Entity/AccompanyingPeriodTest.php b/src/Bundle/ChillPersonBundle/Tests/Entity/AccompanyingPeriodTest.php index a459c3c18..6c78d817d 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Entity/AccompanyingPeriodTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Entity/AccompanyingPeriodTest.php @@ -129,20 +129,27 @@ final class AccompanyingPeriodTest extends \PHPUnit\Framework\TestCase $this->assertNull($period->getPinnedComment()); $period->setPinnedComment($comment); + $this->assertSame($period->getPinnedComment(), $comment); - $this->assertSame($period, $comment->getAccompanyingPeriod()); - $this->assertEquals(0, count($period->getComments()), 'The initial comment should not appears in the list of comments'); + $this->assertNull($comment->getAccompanyingPeriod()); + $this->assertEquals(0, count($period->getComments())); $period->setPinnedComment($replacingComment); + $this->assertSame($period->getPinnedComment(), $replacingComment); - $this->assertSame($period, $replacingComment->getAccompanyingPeriod()); - $this->assertEquals(0, count($period->getComments()), 'The initial comment should not appears in the list of comments'); - $this->assertNull($comment->getAccompanyingPeriod()); + $this->assertNull($replacingComment->getAccompanyingPeriod()); + $this->assertSame($period, $comment->getAccompanyingPeriod()); + $this->assertEquals(1, count($period->getComments())); + $this->assertContains($comment, $period->getComments()); $period->setPinnedComment(null); + $this->assertNull($period->getPinnedComment()); - $this->assertNull($replacingComment->getAccompanyingPeriod()); - $this->assertEquals(0, count($period->getComments()), 'The initial comment should not appears in the list of comments'); + $this->assertSame($period, $comment->getAccompanyingPeriod()); + $this->assertSame($period, $replacingComment->getAccompanyingPeriod()); + $this->assertEquals(2, count($period->getComments())); + $this->assertContains($comment, $period->getComments()); + $this->assertContains($replacingComment, $period->getComments()); } public function testRequestor()