mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-05 14:25:00 +00:00
Merge remote-tracking branch 'origin/master' into rector/rules-up-to-php80
Conflicts: src/Bundle/ChillActivityBundle/Controller/ActivityController.php src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/DateAggregator.php src/Bundle/ChillActivityBundle/Menu/PersonMenuBuilder.php src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php src/Bundle/ChillActivityBundle/Service/DocGenerator/ActivityContext.php src/Bundle/ChillCalendarBundle/Command/MapAndSubscribeUserCalendarCommand.php src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MSGraphUserRepository.php src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseController.php src/Bundle/ChillDocStoreBundle/Controller/DocumentPersonController.php src/Bundle/ChillDocStoreBundle/Repository/PersonDocumentACLAwareRepository.php src/Bundle/ChillEventBundle/Search/EventSearch.php src/Bundle/ChillMainBundle/Controller/ExportController.php src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php src/Bundle/ChillMainBundle/Cron/CronManager.php src/Bundle/ChillMainBundle/Entity/CronJobExecution.php src/Bundle/ChillMainBundle/Export/ExportManager.php src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php src/Bundle/ChillMainBundle/Form/Type/Listing/FilterOrderType.php src/Bundle/ChillMainBundle/Repository/NotificationRepository.php src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperBuilder.php src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperFactory.php src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php src/Bundle/ChillPersonBundle/Controller/SocialWorkSocialActionApiController.php src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/AgeAggregator.php src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php src/Bundle/ChillPersonBundle/Export/Export/ListHouseholdInPeriod.php src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkEvaluationContext.php src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReports.php src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php
This commit is contained in:
@@ -18,6 +18,7 @@ use Chill\PersonBundle\Entity\Person;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
|
||||
/**
|
||||
@@ -39,7 +40,7 @@ final class HouseholdNormalizerTest extends KernelTestCase
|
||||
$this->entityManager = self::$container->get(EntityManagerInterface::class);
|
||||
}
|
||||
|
||||
public function testNormalizationRecursive()
|
||||
public function testNormalizationRecursive(): void
|
||||
{
|
||||
$person = new Person();
|
||||
$person->setFirstName('ok')->setLastName('ok');
|
||||
@@ -67,4 +68,53 @@ final class HouseholdNormalizerTest extends KernelTestCase
|
||||
$this->assertArrayHasKey('type', $normalized);
|
||||
$this->assertEquals('household', $normalized['type']);
|
||||
}
|
||||
|
||||
/**
|
||||
* When a household have old members (members which are not "current"),
|
||||
* the indexes of the household must be reset to numerical and contiguous
|
||||
* indexes. This ensure that it will be mapped as a list, not as an associative
|
||||
* array.
|
||||
*/
|
||||
public function testHouseholdDocGenNormalizationWithOldMembers(): void
|
||||
{
|
||||
$previousPerson = new Person();
|
||||
$previousPerson->setFirstName('ok')->setLastName('ok');
|
||||
$this->entityManager->persist($previousPerson);
|
||||
$member = new HouseholdMember();
|
||||
$household = new Household();
|
||||
$position = (new Position())
|
||||
->setShareHousehold(true)
|
||||
->setAllowHolder(true);
|
||||
|
||||
$member->setPerson($previousPerson)
|
||||
->setStartDate(new DateTimeImmutable('1 year ago'))
|
||||
->setEndDate(new DateTimeImmutable('1 month ago'))
|
||||
->setPosition($position);
|
||||
|
||||
$household->addMember($member);
|
||||
|
||||
$currentPerson1 = new Person();
|
||||
$currentPerson1->setFirstName('p1')->setLastName('p1');
|
||||
$this->entityManager->persist($currentPerson1);
|
||||
$member = new HouseholdMember();
|
||||
$member->setPerson($currentPerson1)
|
||||
->setStartDate(new DateTimeImmutable('1 year ago'))
|
||||
->setPosition($position);
|
||||
$household->addMember($member);
|
||||
|
||||
$normalized = $this->normalizer->normalize(
|
||||
$household,
|
||||
'docgen',
|
||||
[
|
||||
AbstractNormalizer::GROUPS => ['docgen:read'],
|
||||
'docgen:expects' => Household::class,
|
||||
'docgen:person:with-household' => false,
|
||||
'docgen:person:with-relations' => false,
|
||||
'docgen:person:with-budget' => false,
|
||||
]
|
||||
);
|
||||
|
||||
self::assertIsArray($normalized);
|
||||
self::assertArrayHasKey(0, $normalized['currentMembers']);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user