mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-27 17:15:02 +00:00
Add personId
serialization to PersonJsonNormalizer
- Inject `PersonIdRenderingInterface` into `PersonJsonNormalizer` for generating `personId`. - Update `PersonJsonNormalizer` to include `personId` in serialized output. - Extend TypeScript definitions to support `personId` property. - Enhance unit tests to cover `personId` serialization.
This commit is contained in:
@@ -19,6 +19,7 @@ use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Entity\PersonAltName;
|
||||
use Chill\PersonBundle\Repository\ResidentialAddressRepository;
|
||||
use Chill\PersonBundle\Serializer\Normalizer\PersonJsonNormalizer;
|
||||
use Chill\PersonBundle\PersonIdentifier\Rendering\PersonIdRenderingInterface;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Prophecy\Argument;
|
||||
@@ -68,11 +69,13 @@ final class PersonJsonNormalizerTest extends TestCase
|
||||
'email',
|
||||
'gender',
|
||||
'civility',
|
||||
'personId',
|
||||
];
|
||||
|
||||
foreach ($expectedKeys as $key) {
|
||||
self::assertArrayHasKey($key, $data, sprintf('Key %s should be present', $key));
|
||||
}
|
||||
self::assertSame('PERSON-ID-RENDER', $data['personId']);
|
||||
|
||||
// Ensure extended keys are not present in minimal mode
|
||||
foreach (['centers', 'altNames', 'current_household_id', 'current_residential_addresses'] as $key) {
|
||||
@@ -97,7 +100,7 @@ final class PersonJsonNormalizerTest extends TestCase
|
||||
|
||||
// Base keys
|
||||
$baseKeys = [
|
||||
'type', 'id', 'text', 'textAge', 'firstName', 'lastName', 'current_household_address', 'birthdate', 'deathdate', 'age', 'phonenumber', 'mobilenumber', 'email', 'gender', 'civility',
|
||||
'type', 'id', 'text', 'textAge', 'firstName', 'lastName', 'current_household_address', 'birthdate', 'deathdate', 'age', 'phonenumber', 'mobilenumber', 'email', 'gender', 'civility', 'personId',
|
||||
];
|
||||
foreach ($baseKeys as $key) {
|
||||
self::assertArrayHasKey($key, $data, sprintf('Key %s should be present', $key));
|
||||
@@ -129,11 +132,15 @@ final class PersonJsonNormalizerTest extends TestCase
|
||||
|
||||
$phoneHelper = $this->prophesize(PhoneNumberHelperInterface::class);
|
||||
|
||||
$personIdRendering = $this->prophesize(PersonIdRenderingInterface::class);
|
||||
$personIdRendering->renderPersonId(Argument::type(Person::class))->willReturn('PERSON-ID-RENDER');
|
||||
|
||||
$normalizer = new PersonJsonNormalizer(
|
||||
$render->reveal(),
|
||||
$centerResolver->reveal(),
|
||||
$raRepo->reveal(),
|
||||
$phoneHelper->reveal(),
|
||||
$personIdRendering->reveal(),
|
||||
);
|
||||
|
||||
// Inner normalizer that echoes values or simple conversions
|
||||
|
Reference in New Issue
Block a user