Fix loading of CalendarContext in CalendarContextTest. Needs to remove the final from PersonRepository

This commit is contained in:
Julien Fastré 2023-08-28 13:23:10 +02:00
parent d1e09d7047
commit e2d62d5792
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB
3 changed files with 21 additions and 3 deletions

View File

@ -33,8 +33,16 @@ use function count;
final readonly class CalendarContext implements CalendarContextInterface
{
public function __construct(private BaseContextData $baseContextData, private EntityManagerInterface $entityManager, private NormalizerInterface $normalizer, private PersonRender $personRender, private PersonRepository $personRepository, private ThirdPartyRender $thirdPartyRender, private ThirdPartyRepository $thirdPartyRepository, private TranslatableStringHelperInterface $translatableStringHelper)
{
public function __construct(
private BaseContextData $baseContextData,
private EntityManagerInterface $entityManager,
private NormalizerInterface $normalizer,
private PersonRender $personRender,
private PersonRepository $personRepository,
private ThirdPartyRender $thirdPartyRender,
private ThirdPartyRepository $thirdPartyRepository,
private TranslatableStringHelperInterface $translatableStringHelper
) {
}
public function adminFormReverseTransform(array $data): array

View File

@ -19,8 +19,10 @@ use Chill\DocGeneratorBundle\Service\Context\BaseContextData;
use Chill\DocStoreBundle\Entity\StoredObject;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Repository\PersonRepository;
use Chill\PersonBundle\Templating\Entity\PersonRender;
use Chill\ThirdPartyBundle\Entity\ThirdParty;
use Chill\ThirdPartyBundle\Repository\ThirdPartyRepository;
use Chill\ThirdPartyBundle\Templating\Entity\ThirdPartyRender;
use Doctrine\ORM\EntityManagerInterface;
use PHPUnit\Framework\TestCase;
@ -210,9 +212,15 @@ final class CalendarContextTest extends TestCase
$personRender = $this->prophesize(PersonRender::class);
$personRender->renderString(Argument::type(Person::class), [])->willReturn('person name');
$personRepository = $this->prophesize(PersonRepository::class);
$personRepository->find(Argument::type('int'))->willReturn(new Person());
$thirdPartyRender = $this->prophesize(ThirdPartyRender::class);
$thirdPartyRender->renderString(Argument::type(ThirdParty::class), [])->willReturn('third party name');
$thirdPartyRepository = $this->prophesize(ThirdPartyRepository::class);
$thirdPartyRepository->find(Argument::type('int'))->willReturn(new ThirdParty());
$translatableStringHelper = $this->prophesize(TranslatableStringHelperInterface::class);
$translatableStringHelper->localize(Argument::type('array'))->willReturn('blabla');
@ -229,7 +237,9 @@ final class CalendarContextTest extends TestCase
$entityManager,
$normalizer,
$personRender->reveal(),
$personRepository->reveal(),
$thirdPartyRender->reveal(),
$thirdPartyRepository->reveal(),
$translatableStringHelper->reveal()
);
}

View File

@ -22,7 +22,7 @@ use function count;
use function in_array;
use function str_replace;
final class PersonRepository implements ObjectRepository
class PersonRepository implements ObjectRepository
{
private readonly EntityRepository $repository;