From 847fd71364ce9e089d5e06b90ed5280c70a9aac9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 28 Aug 2023 15:32:09 +0200 Subject: [PATCH] Fix tests on PersonContextWithThirdParty: fix construction of PersonContextWithThirdPartyTest --- .../DocGenerator/PersonContextWithThirdParty.php | 7 +++++-- .../DocGenerator/PersonContextWithThirdPartyTest.php | 12 +++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContextWithThirdParty.php b/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContextWithThirdParty.php index 662984011..d865d686a 100644 --- a/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContextWithThirdParty.php +++ b/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContextWithThirdParty.php @@ -27,8 +27,11 @@ use Symfony\Component\Serializer\Normalizer\NormalizerInterface; */ class PersonContextWithThirdParty implements DocGeneratorContextWithAdminFormInterface, DocGeneratorContextWithPublicFormInterface { - public function __construct(private readonly PersonContextInterface $personContext, private readonly NormalizerInterface $normalizer, private readonly ThirdPartyRepository $thirdPartyRepository) - { + public function __construct( + private readonly PersonContextInterface $personContext, + private readonly NormalizerInterface $normalizer, + private readonly ThirdPartyRepository $thirdPartyRepository + ) { } public function adminFormReverseTransform(array $data): array diff --git a/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextWithThirdPartyTest.php b/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextWithThirdPartyTest.php index 70bccfda4..fc3063ebc 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextWithThirdPartyTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextWithThirdPartyTest.php @@ -16,6 +16,7 @@ use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Service\DocGenerator\PersonContextInterface; use Chill\PersonBundle\Service\DocGenerator\PersonContextWithThirdParty; use Chill\ThirdPartyBundle\Entity\ThirdParty; +use Chill\ThirdPartyBundle\Repository\ThirdPartyRepository; use Prophecy\Argument; use Prophecy\PhpUnit\ProphecyTrait; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; @@ -83,9 +84,18 @@ final class PersonContextWithThirdPartyTest extends KernelTestCase $personContext->getData(Argument::type(DocGeneratorTemplate::class), Argument::type(Person::class), Argument::type('array')) ->willReturn(['person' => 'data']); + $thirdPartyRepository = $this->prophesize(ThirdPartyRepository::class); + $thirdPartyRepository->find(Argument::type('int'))->willReturn(new class () extends ThirdParty { + public function getId(): ?int + { + return 1; + } + }); + return new PersonContextWithThirdParty( $personContext->reveal(), - $normalizer->reveal() + $normalizer->reveal(), + $thirdPartyRepository->reveal(), ); } }