This commit is contained in:
Julien Fastré 2025-04-15 14:08:39 +02:00
parent 7e2bf91e09
commit 75932b0e29
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB
4 changed files with 15 additions and 9 deletions

View File

@ -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;

View File

@ -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
{

View File

@ -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);
}
}
}

View File

@ -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));
}
}