normalization for docgen:read: add groups and so on (wip)

This commit is contained in:
Julien Fastré 2021-12-06 13:18:59 +01:00
parent 51fd81c661
commit c4998f4ac1
15 changed files with 166 additions and 70 deletions

View File

@ -90,11 +90,6 @@ final class DocGeneratorTemplateController extends AbstractController
int $entityId, int $entityId,
Request $request Request $request
): Response { ): Response {
$entity = $this->getDoctrine()->getRepository($entityClassName)->find($entityId);
if (null === $entity) {
throw new NotFoundHttpException("Entity with classname {$entityClassName} and id {$entityId} is not found");
}
try { try {
$context = $this->contextManager->getContextByDocGeneratorTemplate($template); $context = $this->contextManager->getContextByDocGeneratorTemplate($template);
@ -102,6 +97,12 @@ final class DocGeneratorTemplateController extends AbstractController
throw new NotFoundHttpException($e->getMessage(), $e); throw new NotFoundHttpException($e->getMessage(), $e);
} }
$entity = $this->getDoctrine()->getRepository($context->getEntityClass())->find($entityId);
if (null === $entity) {
throw new NotFoundHttpException("Entity with classname {$entityClassName} and id {$entityId} is not found");
}
$contextGenerationData = []; $contextGenerationData = [];
if ($context instanceof DocGeneratorContextWithPublicFormInterface if ($context instanceof DocGeneratorContextWithPublicFormInterface

View File

@ -210,7 +210,17 @@ class DocGenObjectNormalizer implements NormalizerAwareInterface, NormalizerInte
$value = $this->propertyAccess->getValue($object, $attribute->getName()); $value = $this->propertyAccess->getValue($object, $attribute->getName());
$key = $attribute->getSerializedName() ?? $attribute->getName(); $key = $attribute->getSerializedName() ?? $attribute->getName();
if (is_object($value)) { if (is_iterable($value)) {
$arr = [];
foreach ($value as $k => $v) {
$arr[$k] =
$this->normalizer->normalize($v, $format, array_merge(
$context,
$attribute->getNormalizationContextForGroups($expectedGroups)
));
}
$data[$key] = $arr;
} elseif (is_object($value)) {
$data[$key] = $data[$key] =
$this->normalizer->normalize($value, $format, array_merge( $this->normalizer->normalize($value, $format, array_merge(
$context, $context,

View File

@ -33,7 +33,7 @@ class Scope
* @ORM\Id * @ORM\Id
* @ORM\Column(name="id", type="integer") * @ORM\Column(name="id", type="integer")
* @ORM\GeneratedValue(strategy="AUTO") * @ORM\GeneratedValue(strategy="AUTO")
* @Groups({"read"}) * @Groups({"read", "docgen:read"})
*/ */
private $id; private $id;
@ -43,7 +43,7 @@ class Scope
* @var array * @var array
* *
* @ORM\Column(type="json") * @ORM\Column(type="json")
* @Groups({"read"}) * @Groups({"read", "docgen:read"})
*/ */
private $name = []; private $name = [];

View File

@ -45,6 +45,6 @@ class UserNormalizer implements NormalizerAwareInterface, NormalizerInterface
public function supportsNormalization($data, ?string $format = null): bool public function supportsNormalization($data, ?string $format = null): bool
{ {
return 'json' === $format && $data instanceof User; return $data instanceof User && ('json' === $format || 'docgen' === $format);
} }
} }

View File

@ -259,7 +259,7 @@ class AccompanyingPeriod implements
* cascade={"persist", "remove"}, * cascade={"persist", "remove"},
* orphanRemoval=true * orphanRemoval=true
* ) * )
* @Groups({"read"}) * @Groups({"read", "docgen:read"})
* @ResourceDuplicateCheck(groups={AccompanyingPeriod::STEP_DRAFT, AccompanyingPeriod::STEP_CONFIRMED, "Default", "default"}) * @ResourceDuplicateCheck(groups={AccompanyingPeriod::STEP_DRAFT, AccompanyingPeriod::STEP_CONFIRMED, "Default", "default"})
*/ */
private Collection $resources; private Collection $resources;
@ -274,7 +274,7 @@ class AccompanyingPeriod implements
* joinColumns={@ORM\JoinColumn(name="accompanying_period_id", referencedColumnName="id")}, * joinColumns={@ORM\JoinColumn(name="accompanying_period_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="scope_id", referencedColumnName="id")} * inverseJoinColumns={@ORM\JoinColumn(name="scope_id", referencedColumnName="id")}
* ) * )
* @Groups({"read"}) * @Groups({"read", "docgen:read"})
* @Assert\Count(min=1, groups={AccompanyingPeriod::STEP_CONFIRMED}, minMessage="A course must be associated to at least one scope") * @Assert\Count(min=1, groups={AccompanyingPeriod::STEP_CONFIRMED}, minMessage="A course must be associated to at least one scope")
*/ */
private Collection $scopes; private Collection $scopes;
@ -340,6 +340,7 @@ class AccompanyingPeriod implements
$this->socialIssues = new ArrayCollection(); $this->socialIssues = new ArrayCollection();
$this->comments = new ArrayCollection(); $this->comments = new ArrayCollection();
$this->works = new ArrayCollection(); $this->works = new ArrayCollection();
$this->resources = new ArrayCollection();
} }
/** /**
@ -575,6 +576,9 @@ class AccompanyingPeriod implements
return $this->createdBy; return $this->createdBy;
} }
/**
* @Groups({"docgen:read"})
*/
public function getCurrentParticipations(): Collection public function getCurrentParticipations(): Collection
{ {
return $this->getOpenParticipations(); return $this->getOpenParticipations();

View File

@ -41,11 +41,10 @@ class Resource
* ) * )
* @ORM\JoinColumn(nullable=false) * @ORM\JoinColumn(nullable=false)
*/ */
private $accompanyingPeriod; private ?AccompanyingPeriod $accompanyingPeriod = null;
/** /**
* @ORM\ManyToOne(targetEntity=Comment::class) * @ORM\ManyToOne(targetEntity=Comment::class)
* @ORM\JoinColumn(nullable=true)
*/ */
private $comment; private $comment;
@ -53,21 +52,23 @@ class Resource
* @ORM\Id * @ORM\Id
* @ORM\GeneratedValue * @ORM\GeneratedValue
* @ORM\Column(type="integer") * @ORM\Column(type="integer")
* @Groups({"read"}) * @Groups({"read", "docgen:read"})
*/ */
private $id; private ?int $id = null;
/** /**
* @ORM\ManyToOne(targetEntity=Person::class) * @ORM\ManyToOne(targetEntity=Person::class)
* @ORM\JoinColumn(nullable=true) * @ORM\JoinColumn(nullable=true)
* @Groups({"docgen:read"})
*/ */
private $person; private ?Person $person = null;
/** /**
* @ORM\ManyToOne(targetEntity=ThirdParty::class) * @ORM\ManyToOne(targetEntity=ThirdParty::class)
* @ORM\JoinColumn(nullable=true) * @ORM\JoinColumn(nullable=true)
* @Groups({"docgen:read"})
*/ */
private $thirdParty; private ?ThirdParty $thirdParty = null;
public function getAccompanyingPeriod(): ?AccompanyingPeriod public function getAccompanyingPeriod(): ?AccompanyingPeriod
{ {

View File

@ -32,38 +32,38 @@ class AccompanyingPeriodParticipation
* @ORM\ManyToOne(targetEntity=AccompanyingPeriod::class, inversedBy="participations", cascade={"persist"}) * @ORM\ManyToOne(targetEntity=AccompanyingPeriod::class, inversedBy="participations", cascade={"persist"})
* @ORM\JoinColumn(name="accompanyingperiod_id", referencedColumnName="id", nullable=false) * @ORM\JoinColumn(name="accompanyingperiod_id", referencedColumnName="id", nullable=false)
*/ */
private $accompanyingPeriod; private ?AccompanyingPeriod $accompanyingPeriod = null;
/** /**
* @ORM\Column(type="date", nullable=true) * @ORM\Column(type="date", nullable=true)
* @Groups({"read", "read:docgen"}) * @Groups({"read", "docgen:read"})
*/ */
private $endDate; private ?\DateTime $endDate = null;
/** /**
* @ORM\Id * @ORM\Id
* @ORM\GeneratedValue * @ORM\GeneratedValue
* @ORM\Column(type="integer") * @ORM\Column(type="integer")
* @Groups({"read", "read:docgen"}) * @Groups({"read", "docgen:read"})
*/ */
private $id; private ?int $id = null;
/** /**
* @ORM\ManyToOne(targetEntity=Person::class, inversedBy="accompanyingPeriodParticipations") * @ORM\ManyToOne(targetEntity=Person::class, inversedBy="accompanyingPeriodParticipations")
* @ORM\JoinColumn(name="person_id", referencedColumnName="id", nullable=false) * @ORM\JoinColumn(name="person_id", referencedColumnName="id", nullable=false)
* @Groups({"read", "read:docgen"}) * @Groups({"read", "docgen:read"})
*/ */
private $person; private ?Person $person = null;
/** /**
* @ORM\Column(type="date", nullable=false) * @ORM\Column(type="date", nullable=false)
* @Groups({"read"}) * @Groups({"read", "docgen:read"})
*/ */
private $startDate; private ?\DateTime $startDate = null;
public function __construct(AccompanyingPeriod $accompanyingPeriod, Person $person) public function __construct(AccompanyingPeriod $accompanyingPeriod, Person $person)
{ {
$this->startDate = new DateTimeImmutable('now'); $this->startDate = new \DateTime('now');
$this->accompanyingPeriod = $accompanyingPeriod; $this->accompanyingPeriod = $accompanyingPeriod;
$this->person = $person; $this->person = $person;
} }
@ -73,10 +73,6 @@ class AccompanyingPeriodParticipation
return $this->accompanyingPeriod; return $this->accompanyingPeriod;
} }
/*
* public function setStartDate(\DateTimeInterface $startDate): self { $this->startDate = $startDate; return $this; }
*/
public function getEndDate(): ?DateTimeInterface public function getEndDate(): ?DateTimeInterface
{ {
return $this->endDate; return $this->endDate;

View File

@ -59,7 +59,7 @@ class Household
* @ORM\Id * @ORM\Id
* @ORM\GeneratedValue * @ORM\GeneratedValue
* @ORM\Column(type="integer") * @ORM\Column(type="integer")
* @Serializer\Groups({"read"}) * @Serializer\Groups({"read", "docgen:read"})
*/ */
private ?int $id = null; private ?int $id = null;
@ -68,17 +68,19 @@ class Household
* targetEntity=HouseholdMember::class, * targetEntity=HouseholdMember::class,
* mappedBy="household" * mappedBy="household"
* ) * )
* @Serializer\Groups({"read"}) * @Serializer\Groups({"read", "docgen:read"})
*/ */
private Collection $members; private Collection $members;
/** /**
* @ORM\Column(type="boolean", name="waiting_for_birth", options={"default": false}) * @ORM\Column(type="boolean", name="waiting_for_birth", options={"default": false})
* @Serializer\Groups({"docgen:read"})
*/ */
private bool $waitingForBirth = false; private bool $waitingForBirth = false;
/** /**
* @ORM\Column(type="date_immutable", name="waiting_for_birth_date", nullable=true, options={"default": null}) * @ORM\Column(type="date_immutable", name="waiting_for_birth_date", nullable=true, options={"default": null})
* @Serializer\Groups({"docgen:read"})
*/ */
private ?DateTimeImmutable $waitingForBirthDate = null; private ?DateTimeImmutable $waitingForBirthDate = null;
@ -134,7 +136,7 @@ class Household
} }
/** /**
* @Serializer\Groups({ "read" }) * @Serializer\Groups({"read", "docgen:read"})
* @Serializer\SerializedName("current_address") * @Serializer\SerializedName("current_address")
*/ */
public function getCurrentAddress(?DateTime $at = null): ?Address public function getCurrentAddress(?DateTime $at = null): ?Address
@ -154,6 +156,11 @@ class Household
return null; return null;
} }
/**
* @param DateTimeImmutable|null $now
* @return Collection
* @Serializer\Groups({"docgen:read"})
*/
public function getCurrentMembers(?DateTimeImmutable $now = null): Collection public function getCurrentMembers(?DateTimeImmutable $now = null): Collection
{ {
return $this->getMembers()->matching($this->buildCriteriaCurrentMembers($now)); return $this->getMembers()->matching($this->buildCriteriaCurrentMembers($now));

View File

@ -28,13 +28,13 @@ class HouseholdMember
{ {
/** /**
* @ORM\Column(type="string", length=255, nullable=true) * @ORM\Column(type="string", length=255, nullable=true)
* @Serializer\Groups({"read"}) * @Serializer\Groups({"read", "docgen:read"})
*/ */
private ?string $comment = null; private ?string $comment = null;
/** /**
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null}) * @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
* @Serializer\Groups({"read"}) * @Serializer\Groups({"read", "docgen:read"})
* @Assert\GreaterThan( * @Assert\GreaterThan(
* propertyPath="startDate", * propertyPath="startDate",
* message="household_membership.The end date must be after start date", * message="household_membership.The end date must be after start date",
@ -45,7 +45,7 @@ class HouseholdMember
/** /**
* @ORM\Column(type="boolean", options={"default": false}) * @ORM\Column(type="boolean", options={"default": false})
* @Serializer\Groups({"read"}) * @Serializer\Groups({"read", "docgen:read"})
*/ */
private bool $holder = false; private bool $holder = false;
@ -63,7 +63,7 @@ class HouseholdMember
* @ORM\Id * @ORM\Id
* @ORM\GeneratedValue * @ORM\GeneratedValue
* @ORM\Column(type="integer") * @ORM\Column(type="integer")
* @Serializer\Groups({"read"}) * @Serializer\Groups({"read", "docgen:read"})
*/ */
private $id; private $id;
@ -72,7 +72,7 @@ class HouseholdMember
* @ORM\ManyToOne( * @ORM\ManyToOne(
* targetEntity="\Chill\PersonBundle\Entity\Person" * targetEntity="\Chill\PersonBundle\Entity\Person"
* ) * )
* @Serializer\Groups({"read"}) * @Serializer\Groups({"read", "docgen:read"})
* @Assert\Valid(groups={"household_memberships"}) * @Assert\Valid(groups={"household_memberships"})
* @Assert\NotNull(groups={"household_memberships"}) * @Assert\NotNull(groups={"household_memberships"})
*/ */
@ -80,7 +80,7 @@ class HouseholdMember
/** /**
* @ORM\ManyToOne(targetEntity=Position::class) * @ORM\ManyToOne(targetEntity=Position::class)
* @Serializer\Groups({"read"}) * @Serializer\Groups({"read", "docgen:read"})
* @Assert\NotNull(groups={"household_memberships_created"}) * @Assert\NotNull(groups={"household_memberships_created"})
*/ */
private ?Position $position = null; private ?Position $position = null;
@ -92,7 +92,7 @@ class HouseholdMember
/** /**
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null}) * @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
* @Serializer\Groups({"read"}) * @Serializer\Groups({"read", "docgen:read"})
* @Assert\NotNull(groups={"household_memberships"}) * @Assert\NotNull(groups={"household_memberships"})
*/ */
private ?DateTimeImmutable $startDate = null; private ?DateTimeImmutable $startDate = null;

View File

@ -33,25 +33,25 @@ class Position
* @ORM\Id * @ORM\Id
* @ORM\GeneratedValue * @ORM\GeneratedValue
* @ORM\Column(type="integer") * @ORM\Column(type="integer")
* @Serializer\Groups({ "read" }) * @Serializer\Groups({"read", "docgen:read"})
*/ */
private ?int $id; private ?int $id;
/** /**
* @ORM\Column(type="json") * @ORM\Column(type="json")
* @Serializer\Groups({ "read" }) * @Serializer\Groups({"read", "docgen:read"})
*/ */
private array $label = []; private array $label = [];
/** /**
* @ORM\Column(type="float") * @ORM\Column(type="float")
* @Serializer\Groups({ "read" }) * @Serializer\Groups({"read"})
*/ */
private float $ordering = 0.00; private float $ordering = 0.00;
/** /**
* @ORM\Column(type="boolean") * @ORM\Column(type="boolean")
* @Serializer\Groups({ "read" }) * @Serializer\Groups({"read"})
*/ */
private bool $shareHouseHold = true; private bool $shareHouseHold = true;

View File

@ -38,7 +38,7 @@ class Goal
* @ORM\Id * @ORM\Id
* @ORM\GeneratedValue * @ORM\GeneratedValue
* @ORM\Column(type="integer") * @ORM\Column(type="integer")
* @Serializer\Groups({"read"}) * @Serializer\Groups({"read", "docgen:read"})
*/ */
private $id; private $id;
@ -55,7 +55,7 @@ class Goal
/** /**
* @ORM\Column(type="json") * @ORM\Column(type="json")
* @Serializer\Groups({"read"}) * @Serializer\Groups({"read", "docgen:read"})
*/ */
private $title = []; private $title = [];

View File

@ -55,7 +55,7 @@ class Result
* @ORM\Id * @ORM\Id
* @ORM\GeneratedValue * @ORM\GeneratedValue
* @ORM\Column(type="integer") * @ORM\Column(type="integer")
* @Serializer\Groups({"read"}) * @Serializer\Groups({"read", "docgen:read"})
*/ */
private $id; private $id;
@ -66,7 +66,7 @@ class Result
/** /**
* @ORM\Column(type="json") * @ORM\Column(type="json")
* @Serializer\Groups({"read"}) * @Serializer\Groups({"read", "docgen:read"})
*/ */
private $title = []; private $title = [];

View File

@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Serializer\Normalizer; namespace Chill\PersonBundle\Serializer\Normalizer;
use Chill\PersonBundle\Entity\SocialWork\SocialAction; use Chill\PersonBundle\Entity\SocialWork\SocialAction;
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
use Chill\PersonBundle\Templating\Entity\SocialActionRender; use Chill\PersonBundle\Templating\Entity\SocialActionRender;
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface; use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait; use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
@ -30,18 +31,48 @@ class SocialActionNormalizer implements NormalizerAwareInterface, NormalizerInte
public function normalize($socialAction, ?string $format = null, array $context = []) public function normalize($socialAction, ?string $format = null, array $context = [])
{ {
return [ switch ($format) {
'id' => $socialAction->getId(), case 'json':
'type' => 'social_work_social_action', return [
'text' => $this->render->renderString($socialAction, []), 'id' => $socialAction->getId(),
'parent' => $this->normalizer->normalize($socialAction->getParent()), 'type' => 'social_work_social_action',
'desactivationDate' => $this->normalizer->normalize($socialAction->getDesactivationDate()), 'text' => $this->render->renderString($socialAction, []),
'title' => $socialAction->getTitle(), 'parent' => $this->normalizer->normalize($socialAction->getParent()),
]; 'desactivationDate' => $this->normalizer->normalize($socialAction->getDesactivationDate()),
'title' => $socialAction->getTitle(),
];
case 'docgen':
if (null === $socialAction) {
return ['id' => 0, 'title' => '', 'text' => ''];
}
return [
'id' => $socialAction->getId(),
'text' => $this->render->renderString($socialAction, []),
'title' => $socialAction->getTitle(),
];
default:
throw new \Symfony\Component\Serializer\Exception\RuntimeException("format not supported");
}
} }
public function supportsNormalization($data, ?string $format = null) public function supportsNormalization($data, string $format = null, array $context = [])
{ {
return $data instanceof SocialAction; if ($data instanceof SocialAction && 'json' === $format) {
return true;
}
if ('docgen' === $format) {
if ($data instanceof SocialAction) {
return true;
}
if (null === $data && ($context['docgen:expects'] ?? null) === SocialAction::class) {
return true;
}
}
return false;
} }
} }

View File

@ -13,11 +13,12 @@ namespace Chill\PersonBundle\Serializer\Normalizer;
use Chill\PersonBundle\Entity\SocialWork\SocialIssue; use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
use Chill\PersonBundle\Templating\Entity\SocialIssueRender; use Chill\PersonBundle\Templating\Entity\SocialIssueRender;
use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface; use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait; use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface; use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
class SocialIssueNormalizer implements NormalizerAwareInterface, NormalizerInterface class SocialIssueNormalizer implements NormalizerAwareInterface, ContextAwareNormalizerInterface
{ {
use NormalizerAwareTrait; use NormalizerAwareTrait;
@ -31,18 +32,46 @@ class SocialIssueNormalizer implements NormalizerAwareInterface, NormalizerInter
public function normalize($socialIssue, ?string $format = null, array $context = []) public function normalize($socialIssue, ?string $format = null, array $context = [])
{ {
/** @var SocialIssue $socialIssue */ /** @var SocialIssue $socialIssue */
return [ switch ($format) {
'type' => 'social_issue', case 'json':
'id' => $socialIssue->getId(), return [
'parent_id' => $socialIssue->hasParent() ? $socialIssue->getParent()->getId() : null, 'type' => 'social_issue',
'children_ids' => $socialIssue->getChildren()->map(static function (SocialIssue $si) { return $si->getId(); }), 'id' => $socialIssue->getId(),
'title' => $socialIssue->getTitle(), 'parent_id' => $socialIssue->hasParent() ? $socialIssue->getParent()->getId() : null,
'text' => $this->render->renderString($socialIssue, []), 'children_ids' => $socialIssue->getChildren()->map(static function (SocialIssue $si) { return $si->getId(); }),
]; 'title' => $socialIssue->getTitle(),
'text' => $this->render->renderString($socialIssue, []),
];
case 'docgen':
if (null === $socialIssue) {
return ['id' => 0, 'title' => '', 'text' => ''];
}
return [
'id' => $socialIssue->getId(),
'title' => $socialIssue->getTitle(),
'text' => $this->render->renderString($socialIssue, []),
];
}
} }
public function supportsNormalization($data, ?string $format = null): bool public function supportsNormalization($data, string $format = null, array $context = [])
{ {
return $data instanceof SocialIssue; if ($data instanceof SocialIssue && 'json' === $format) {
return true;
}
if ('docgen' === $format) {
if ($data instanceof SocialIssue) {
return true;
}
if (null === $data && ($context['docgen:expects'] ?? null) === SocialIssue::class) {
return true;
}
}
return false;
} }
} }

View File

@ -13,6 +13,7 @@ namespace Serializer\Normalizer;
use Chill\MainBundle\Entity\Scope; use Chill\MainBundle\Entity\Scope;
use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Entity\SocialWork\SocialIssue; use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface; use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
@ -79,6 +80,22 @@ final class AccompanyingPeriodDocGenNormalizerTest extends KernelTestCase
} }
} }
public function testNormalizeParticipations()
{
$period = new AccompanyingPeriod();
$period->addPerson($person = new Person());
$person->setFirstName('test');
$data = $this->normalizer->normalize($period, 'docgen', ['docgen:expects' => AccompanyingPeriod::class]);
$this->assertIsArray($data);
$this->assertArrayHasKey('participations', $data);
$this->assertCount(1, $data['participations']);
$this->assertArrayHasKey('currentParticipations', $data);
$this->assertCount(1, $data['currentParticipations']);
}
public function testNormalizeNull() public function testNormalizeNull()
{ {
$data = $this->normalizer->normalize(null, 'docgen', ['docgen:expects' => AccompanyingPeriod::class]); $data = $this->normalizer->normalize(null, 'docgen', ['docgen:expects' => AccompanyingPeriod::class]);