diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkGoal.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkGoal.php index 8e78f40fb..f308c219b 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkGoal.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkGoal.php @@ -99,14 +99,6 @@ class AccompanyingPeriodWorkGoal public function setAccompanyingPeriodWork(?AccompanyingPeriodWork $accompanyingPeriodWork): self { - if ( - $this->accompanyingPeriodWork instanceof AccompanyingPeriodWork - && $accompanyingPeriodWork !== $this->accompanyingPeriodWork - && null !== $accompanyingPeriodWork - ) { - throw new \LogicException('Change accompanying period work is not allowed'); - } - $this->accompanyingPeriodWork = $accompanyingPeriodWork; return $this; diff --git a/src/Bundle/ChillPersonBundle/Form/Type/PickLinkedAccompanyingPeriodWorkType.php b/src/Bundle/ChillPersonBundle/Form/Type/PickLinkedAccompanyingPeriodWorkType.php index a2a282d19..55eda49e6 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/PickLinkedAccompanyingPeriodWorkType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/PickLinkedAccompanyingPeriodWorkType.php @@ -16,7 +16,6 @@ use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\FormView; use Symfony\Component\OptionsResolver\OptionsResolver; -use Symfony\Component\Serializer\Normalizer\NormalizerInterface; class PickLinkedAccompanyingPeriodWorkType extends AbstractType { diff --git a/src/Bundle/ChillPersonBundle/Service/AccompanyingPeriodWork/AccompanyingPeriodWorkMergeService.php b/src/Bundle/ChillPersonBundle/Service/AccompanyingPeriodWork/AccompanyingPeriodWorkMergeService.php index 6ad799c76..ba0f93ce3 100644 --- a/src/Bundle/ChillPersonBundle/Service/AccompanyingPeriodWork/AccompanyingPeriodWorkMergeService.php +++ b/src/Bundle/ChillPersonBundle/Service/AccompanyingPeriodWork/AccompanyingPeriodWorkMergeService.php @@ -100,5 +100,13 @@ class AccompanyingPeriodWorkMergeService foreach ($toDelete->getThirdParties() as $thirdParty) { $toKeep->addThirdParty($thirdParty); } + + foreach ($toDelete->getGoals() as $goal) { + $toKeep->addGoal($goal); + } + + foreach ($toDelete->getResults() as $result) { + $toKeep->addResult($result); + } } } diff --git a/src/Bundle/ChillPersonBundle/Tests/Service/AccompanyingPeriodWork/AccompanyingPeriodWorkMergeServiceTest.php b/src/Bundle/ChillPersonBundle/Tests/Service/AccompanyingPeriodWork/AccompanyingPeriodWorkMergeServiceTest.php index 442842112..e69c8beee 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Service/AccompanyingPeriodWork/AccompanyingPeriodWorkMergeServiceTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Service/AccompanyingPeriodWork/AccompanyingPeriodWorkMergeServiceTest.php @@ -14,6 +14,8 @@ namespace Chill\PersonBundle\Tests\Service\AccompanyingPeriodWork; use Chill\MainBundle\Entity\User; use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork; use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation; +use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkGoal; +use Chill\PersonBundle\Entity\SocialWork\Result; use Chill\PersonBundle\Service\AccompanyingPeriodWork\AccompanyingPeriodWorkMergeService; use Chill\ThirdPartyBundle\Entity\ThirdParty; use Doctrine\DBAL\Connection; @@ -175,6 +177,8 @@ class AccompanyingPeriodWorkMergeServiceTest extends TestCase $toDelete->addAccompanyingPeriodWorkEvaluation($evaluationB = new AccompanyingPeriodWorkEvaluation()); $toDelete->setNote('boum'); $toDelete->addThirdParty($thirdPartyB = new ThirdParty()); + $toDelete->addGoal($goalA = new AccompanyingPeriodWorkGoal()); + $toDelete->addResult($resultA = new Result()); $service = $this->buildMergeService($toDelete); $service->merge($accompanyingPeriodWork, $toDelete); @@ -194,5 +198,8 @@ class AccompanyingPeriodWorkMergeServiceTest extends TestCase self::assertTrue($accompanyingPeriodWork->getThirdParties()->contains($thirdPartyA)); self::assertTrue($accompanyingPeriodWork->getThirdParties()->contains($thirdPartyB)); + + self::assertTrue($accompanyingPeriodWork->getGoals()->contains($goalA)); + self::assertTrue($accompanyingPeriodWork->getResults()->contains($resultA)); } }