Fix tests on PersonContextWithThirdParty: fix construction of PersonContextWithThirdPartyTest

This commit is contained in:
Julien Fastré 2023-08-28 15:32:09 +02:00
parent 667104a595
commit 847fd71364
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB
2 changed files with 16 additions and 3 deletions

View File

@ -27,8 +27,11 @@ use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
*/ */
class PersonContextWithThirdParty implements DocGeneratorContextWithAdminFormInterface, DocGeneratorContextWithPublicFormInterface 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 public function adminFormReverseTransform(array $data): array

View File

@ -16,6 +16,7 @@ use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Service\DocGenerator\PersonContextInterface; use Chill\PersonBundle\Service\DocGenerator\PersonContextInterface;
use Chill\PersonBundle\Service\DocGenerator\PersonContextWithThirdParty; use Chill\PersonBundle\Service\DocGenerator\PersonContextWithThirdParty;
use Chill\ThirdPartyBundle\Entity\ThirdParty; use Chill\ThirdPartyBundle\Entity\ThirdParty;
use Chill\ThirdPartyBundle\Repository\ThirdPartyRepository;
use Prophecy\Argument; use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\PhpUnit\ProphecyTrait;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; 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')) $personContext->getData(Argument::type(DocGeneratorTemplate::class), Argument::type(Person::class), Argument::type('array'))
->willReturn(['person' => 'data']); ->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( return new PersonContextWithThirdParty(
$personContext->reveal(), $personContext->reveal(),
$normalizer->reveal() $normalizer->reveal(),
$thirdPartyRepository->reveal(),
); );
} }
} }