mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Fixes
This commit is contained in:
parent
7e2bf91e09
commit
75932b0e29
@ -99,14 +99,6 @@ class AccompanyingPeriodWorkGoal
|
|||||||
|
|
||||||
public function setAccompanyingPeriodWork(?AccompanyingPeriodWork $accompanyingPeriodWork): self
|
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;
|
$this->accompanyingPeriodWork = $accompanyingPeriodWork;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -16,7 +16,6 @@ use Symfony\Component\Form\AbstractType;
|
|||||||
use Symfony\Component\Form\FormInterface;
|
use Symfony\Component\Form\FormInterface;
|
||||||
use Symfony\Component\Form\FormView;
|
use Symfony\Component\Form\FormView;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
|
||||||
|
|
||||||
class PickLinkedAccompanyingPeriodWorkType extends AbstractType
|
class PickLinkedAccompanyingPeriodWorkType extends AbstractType
|
||||||
{
|
{
|
||||||
|
@ -100,5 +100,13 @@ class AccompanyingPeriodWorkMergeService
|
|||||||
foreach ($toDelete->getThirdParties() as $thirdParty) {
|
foreach ($toDelete->getThirdParties() as $thirdParty) {
|
||||||
$toKeep->addThirdParty($thirdParty);
|
$toKeep->addThirdParty($thirdParty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach ($toDelete->getGoals() as $goal) {
|
||||||
|
$toKeep->addGoal($goal);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($toDelete->getResults() as $result) {
|
||||||
|
$toKeep->addResult($result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,8 @@ namespace Chill\PersonBundle\Tests\Service\AccompanyingPeriodWork;
|
|||||||
use Chill\MainBundle\Entity\User;
|
use Chill\MainBundle\Entity\User;
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
|
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation;
|
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\PersonBundle\Service\AccompanyingPeriodWork\AccompanyingPeriodWorkMergeService;
|
||||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||||
use Doctrine\DBAL\Connection;
|
use Doctrine\DBAL\Connection;
|
||||||
@ -175,6 +177,8 @@ class AccompanyingPeriodWorkMergeServiceTest extends TestCase
|
|||||||
$toDelete->addAccompanyingPeriodWorkEvaluation($evaluationB = new AccompanyingPeriodWorkEvaluation());
|
$toDelete->addAccompanyingPeriodWorkEvaluation($evaluationB = new AccompanyingPeriodWorkEvaluation());
|
||||||
$toDelete->setNote('boum');
|
$toDelete->setNote('boum');
|
||||||
$toDelete->addThirdParty($thirdPartyB = new ThirdParty());
|
$toDelete->addThirdParty($thirdPartyB = new ThirdParty());
|
||||||
|
$toDelete->addGoal($goalA = new AccompanyingPeriodWorkGoal());
|
||||||
|
$toDelete->addResult($resultA = new Result());
|
||||||
|
|
||||||
$service = $this->buildMergeService($toDelete);
|
$service = $this->buildMergeService($toDelete);
|
||||||
$service->merge($accompanyingPeriodWork, $toDelete);
|
$service->merge($accompanyingPeriodWork, $toDelete);
|
||||||
@ -194,5 +198,8 @@ class AccompanyingPeriodWorkMergeServiceTest extends TestCase
|
|||||||
|
|
||||||
self::assertTrue($accompanyingPeriodWork->getThirdParties()->contains($thirdPartyA));
|
self::assertTrue($accompanyingPeriodWork->getThirdParties()->contains($thirdPartyA));
|
||||||
self::assertTrue($accompanyingPeriodWork->getThirdParties()->contains($thirdPartyB));
|
self::assertTrue($accompanyingPeriodWork->getThirdParties()->contains($thirdPartyB));
|
||||||
|
|
||||||
|
self::assertTrue($accompanyingPeriodWork->getGoals()->contains($goalA));
|
||||||
|
self::assertTrue($accompanyingPeriodWork->getResults()->contains($resultA));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user