diff --git a/.junie/guidelines.md b/.junie/guidelines.md index ad355eac7..3a9be57e7 100644 --- a/.junie/guidelines.md +++ b/.junie/guidelines.md @@ -363,6 +363,8 @@ The project can be deployed in a production environment following Symfony's depl Comprehensive documentation is available in the `/docs/` directory, including installation instructions, configuration guides, and operational procedures. +This documentation is written using the mkdocs tool. + ## Development Workflow 1. **Create a Feature Branch**: Always create a new branch for your feature or bugfix diff --git a/src/Bundle/ChillMainBundle/Entity/Gender.php b/src/Bundle/ChillMainBundle/Entity/Gender.php index 482c46e14..0ab37d480 100644 --- a/src/Bundle/ChillMainBundle/Entity/Gender.php +++ b/src/Bundle/ChillMainBundle/Entity/Gender.php @@ -47,7 +47,7 @@ class Gender #[ORM\Column(type: \Doctrine\DBAL\Types\Types::FLOAT, name: 'ordering', nullable: true, options: ['default' => '0.0'])] private float $order = 0; - public function getId(): int + public function getId(): ?int { return $this->id; } diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodDocGenNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodDocGenNormalizer.php index 8538613dd..085e09f2b 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodDocGenNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodDocGenNormalizer.php @@ -186,6 +186,6 @@ class AccompanyingPeriodDocGenNormalizer implements NormalizerInterface, Normali public function getSupportedTypes(?string $format): array { - return 'docgen' === $format ? [AccompanyingPeriod::class => true] : []; + return 'docgen' === $format ? [AccompanyingPeriod::class => true, '*' => false] : []; } } diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/GenderDocGenNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/GenderDocGenNormalizer.php index 4c1ae6c92..674a93fd4 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/GenderDocGenNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/GenderDocGenNormalizer.php @@ -34,13 +34,12 @@ class GenderDocGenNormalizer implements NormalizerInterface, NormalizerAwareInte 'id' => $gender->getId(), 'label' => $this->translatableStringHelper->localize($gender->getLabel()), 'genderTranslation' => $gender->getGenderTranslation(), + 'isNull' => false, ]; } public function getSupportedTypes(?string $format): array { - return [ - Gender::class => true, - ]; + return 'docgen' === $format ? [Gender::class => true, '*' => false] : []; } } diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonDocGenNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonDocGenNormalizer.php index 934b81d86..e77cb333b 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonDocGenNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonDocGenNormalizer.php @@ -76,7 +76,7 @@ class PersonDocGenNormalizer implements return $this->normalizeNullValue($format, $context); } - $data = [ + $result = [ 'type' => 'person', 'id' => $data->getId(), 'isNull' => false, @@ -113,7 +113,7 @@ class PersonDocGenNormalizer implements ]; if ($context['docgen:person:with-household'] ?? false) { - $data['household'] = $this->normalizer->normalize( + $result['household'] = $this->normalizer->normalize( $data->getCurrentHousehold(), $format, array_merge($context, [ @@ -126,7 +126,7 @@ class PersonDocGenNormalizer implements } if ($context['docgen:person:with-relations'] ?? false) { - $data['relations'] = $this->normalizer->normalize( + $result['relations'] = $this->normalizer->normalize( new ArrayCollection($this->relationshipRepository->findByPerson($data)), $format, array_merge($context, [ @@ -139,14 +139,14 @@ class PersonDocGenNormalizer implements } if ($context['docgen:person:with-budget'] ?? false) { - $data['budget']['person'] = $this->summaryBudget->getSummaryForPerson($data); + $result['budget']['person'] = $this->summaryBudget->getSummaryForPerson($data); if ($context['docgen:person:with-household'] ?? false) { - $data['budget']['household'] = $this->summaryBudget->getSummaryForHousehold($data->getCurrentHousehold()); + $result['budget']['household'] = $this->summaryBudget->getSummaryForHousehold($data->getCurrentHousehold()); } } - return $data; + return $result; } public function supportsNormalization($data, $format = null, array $context = []): bool @@ -249,6 +249,6 @@ class PersonDocGenNormalizer implements public function getSupportedTypes(?string $format): array { - return 'docgen' === $format ? [Person::class => true] : []; + return 'docgen' === $format ? [Person::class => true, '*' => false] : []; } } diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/RelationshipDocGenNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/RelationshipDocGenNormalizer.php index f28d152c3..a300081ae 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/RelationshipDocGenNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/RelationshipDocGenNormalizer.php @@ -86,6 +86,6 @@ class RelationshipDocGenNormalizer implements NormalizerInterface, NormalizerAwa public function getSupportedTypes(?string $format): array { - return 'docgen' === $format ? [Relationship::class => true] : []; + return 'docgen' === $format ? [Relationship::class => true, '*' => false] : []; } } diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialActionNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialActionNormalizer.php index 4902756fb..3826b6149 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialActionNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialActionNormalizer.php @@ -94,12 +94,10 @@ class SocialActionNormalizer implements NormalizerAwareInterface, NormalizerInte public function getSupportedTypes(?string $format): array { - if ('json' === $format || 'docgen' === $format) { - return [ - SocialAction::class => true, - ]; - } - - return []; + return match ($format) { + 'json' => [SocialAction::class => true], + 'docgen' => [SocialAction::class => true, '*' => false], + default => [], + }; } } diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialIssueNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialIssueNormalizer.php index 4f9c8baf0..c8f828d37 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialIssueNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialIssueNormalizer.php @@ -75,12 +75,10 @@ class SocialIssueNormalizer implements NormalizerInterface, NormalizerAwareInter public function getSupportedTypes(?string $format): array { - if ('json' === $format || 'docgen' === $format) { - return [ - SocialIssue::class => true, - ]; - } - - return []; + return match ($format) { + 'json' => [SocialIssue::class => true], + 'docgen' => [SocialIssue::class => true, '*' => false], + default => [], + }; } } diff --git a/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/AccompanyingPeriodDocGenNormalizerTest.php b/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/AccompanyingPeriodDocGenNormalizerTest.php index 72a2c873f..911a42260 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/AccompanyingPeriodDocGenNormalizerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/AccompanyingPeriodDocGenNormalizerTest.php @@ -11,11 +11,11 @@ declare(strict_types=1); namespace Serializer\Normalizer; +use Chill\DocGeneratorBundle\Test\DocGenNormalizerTestAbstract; use Chill\MainBundle\Entity\Scope; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Entity\SocialWork\SocialIssue; -use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; /** @@ -23,9 +23,36 @@ use Symfony\Component\Serializer\Normalizer\NormalizerInterface; * * @coversNothing */ -final class AccompanyingPeriodDocGenNormalizerTest extends KernelTestCase +final class AccompanyingPeriodDocGenNormalizerTest extends DocGenNormalizerTestAbstract { - private NormalizerInterface $normalizer; + protected NormalizerInterface $normalizer; + + protected function getNormalizer(): NormalizerInterface + { + return $this->normalizer; + } + + public function provideNotNullObject(): object + { + $period = new AccompanyingPeriod(); + $period->setConfidential(true); + $period->setEmergency(true); + $period->setOrigin(new AccompanyingPeriod\Origin()->setLabel(['fr' => 'origin'])); + $period->setClosingMotive(new AccompanyingPeriod\ClosingMotive()->setName(['closing'])); + $period->addScope(new Scope()->setName(['fr' => 'scope1'])); + $period->addScope(new Scope()->setName(['fr' => 'scope2'])); + $period->addSocialIssue(new SocialIssue()->setTitle(['fr' => 'issue1'])); + $period->addSocialIssue(new SocialIssue()->setTitle(['fr' => 'issue2'])); + $period->addPerson(new Person()); + $period->addPerson(new Person()); + + return $period; + } + + public function provideDocGenExpectClass(): string + { + return AccompanyingPeriod::class; + } protected function setUp(): void { diff --git a/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/GenderDocGenNormalizerTest.php b/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/GenderDocGenNormalizerTest.php new file mode 100644 index 000000000..9fe135f8a --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/GenderDocGenNormalizerTest.php @@ -0,0 +1,40 @@ +setLabel(['fr' => 'gender']); + $gender->setGenderTranslation(GenderEnum::FEMALE); + $gender->setIcon(GenderIconEnum::AMBIGUOUS); + + return $gender; + } + + public function provideDocGenExpectClass(): string + { + return Gender::class; + } +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/PersonDocGenNormalizerTest.php b/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/PersonDocGenNormalizerTest.php index 059d99872..0391845b3 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/PersonDocGenNormalizerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/PersonDocGenNormalizerTest.php @@ -12,6 +12,7 @@ declare(strict_types=1); namespace Serializer\Normalizer; use Chill\BudgetBundle\Service\Summary\SummaryBudgetInterface; +use Chill\DocGeneratorBundle\Test\DocGenNormalizerTestAbstract; use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\MainBundle\Templating\TranslatableStringHelperInterface; use Chill\PersonBundle\Entity\Household\Household; @@ -25,7 +26,6 @@ use Chill\PersonBundle\Serializer\Normalizer\PersonDocGenNormalizer; use Chill\PersonBundle\Templating\Entity\PersonRender; use Prophecy\Argument; use Prophecy\PhpUnit\ProphecyTrait; -use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; use Symfony\Contracts\Translation\TranslatorInterface; @@ -34,7 +34,7 @@ use Symfony\Contracts\Translation\TranslatorInterface; * * @coversNothing */ -final class PersonDocGenNormalizerTest extends KernelTestCase +final class PersonDocGenNormalizerTest extends DocGenNormalizerTestAbstract { use ProphecyTrait; @@ -68,7 +68,47 @@ final class PersonDocGenNormalizerTest extends KernelTestCase 'center' => '@ignored', ]; - private NormalizerInterface $normalizer; + protected NormalizerInterface $normalizer; + + protected function getNormalizer(): NormalizerInterface + { + return $this->normalizer; + } + + public function provideNotNullObject(): object + { + $household = new Household(); + $person = new Person(); + $person + ->setFirstName('Renaud') + ->setLastName('Mégane'); + $householdMember = new HouseholdMember(); + $householdMember + ->setPosition(new Position()->setAllowHolder(true)->setLabel(['fr' => 'position']) + ->setShareHousehold(true)) + ->setHolder(true); + $person->addHouseholdParticipation($householdMember); + $household->addMember($householdMember); + + $person = new Person(); + $person + ->setFirstName('Citroen') + ->setLastName('Xsara'); + $householdMember = new HouseholdMember(); + $householdMember + ->setPosition(new Position()->setAllowHolder(true)->setLabel(['fr' => 'position2']) + ->setShareHousehold(true)) + ->setHolder(false); + $person->addHouseholdParticipation($householdMember); + $household->addMember($householdMember); + + return $person; + } + + public function provideDocGenExpectClass(): string + { + return Person::class; + } protected function setUp(): void { diff --git a/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/RelationshipDocGenNormalizerTest.php b/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/RelationshipDocGenNormalizerTest.php index 35045d1d8..7f10ed5c7 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/RelationshipDocGenNormalizerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/RelationshipDocGenNormalizerTest.php @@ -11,12 +11,12 @@ declare(strict_types=1); namespace Serializer\Normalizer; +use Chill\DocGeneratorBundle\Test\DocGenNormalizerTestAbstract; use Chill\MainBundle\Templating\TranslatableStringHelperInterface; use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Entity\Relationships\Relation; use Chill\PersonBundle\Entity\Relationships\Relationship; use Chill\PersonBundle\Serializer\Normalizer\RelationshipDocGenNormalizer; -use PHPUnit\Framework\TestCase; use Prophecy\Argument; use Prophecy\PhpUnit\ProphecyTrait; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; @@ -26,10 +26,30 @@ use Symfony\Component\Serializer\Normalizer\NormalizerInterface; * * @coversNothing */ -final class RelationshipDocGenNormalizerTest extends TestCase +final class RelationshipDocGenNormalizerTest extends DocGenNormalizerTestAbstract { use ProphecyTrait; + public function provideNotNullObject(): object + { + $relationship = new Relationship(); + $relationship + ->setFromPerson($person1 = new Person()) + ->setToPerson($person2 = new Person()) + ->setRelation( + new Relation()->setTitle(['fr' => 'title']) + ->setReverseTitle(['fr' => 'reverse title']) + ) + ->setReverse(false); + + return $relationship; + } + + public function provideDocGenExpectClass(): string + { + return Relationship::class; + } + public function testNormalizeRelationshipNull(): void { $relationship = null; diff --git a/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/SocialActionDocGenNormalizerTest.php b/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/SocialActionDocGenNormalizerTest.php new file mode 100644 index 000000000..236b54931 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/SocialActionDocGenNormalizerTest.php @@ -0,0 +1,38 @@ +setTitle(['fr' => 'my action']); + $action->setIssue(new SocialIssue()); + + return $action; + } + + public function provideDocGenExpectClass(): string + { + return SocialAction::class; + } +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/SocialIssueDocGenNormalizerTest.php b/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/SocialIssueDocGenNormalizerTest.php new file mode 100644 index 000000000..40d3470ea --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/SocialIssueDocGenNormalizerTest.php @@ -0,0 +1,36 @@ +setTitle(['fr' => 'my issue']); + + return $issue; + } + + public function provideDocGenExpectClass(): string + { + return SocialIssue::class; + } +}