Replaced the deprecated 'self::$container->get' with 'self::getContainer()->get' using rector

This change is made to comply with the new Symfony standards and to avoid deprecation warnings for future versions. The update touches various functionalities, including retrieving EntityManagerInterface instance and various service classes within the test files.
This commit is contained in:
2023-12-14 23:36:56 +01:00
parent 4a99480f50
commit 1098bafd3d
248 changed files with 631 additions and 628 deletions

View File

@@ -58,16 +58,16 @@ class AccompanyingPeriodContextTest extends KernelTestCase
protected function setUp(): void
{
self::bootKernel();
$this->baseContextData = self::$container->get(BaseContextData::class);
$this->documentCategoryRepository = self::$container->get(DocumentCategoryRepository::class);
$this->em = self::$container->get(EntityManagerInterface::class);
$this->normalizer = self::$container->get(NormalizerInterface::class);
$this->personRender = self::$container->get(PersonRenderInterface::class);
$this->personRepository = self::$container->get(PersonRepository::class);
$this->translatableStringHelper = self::$container->get(TranslatableStringHelperInterface::class);
$this->translator = self::$container->get(TranslatorInterface::class);
$this->thirdPartyRender = self::$container->get(ThirdPartyRender::class);
$this->thirdPartyRepository = self::$container->get(ThirdPartyRepository::class);
$this->baseContextData = self::getContainer()->get(BaseContextData::class);
$this->documentCategoryRepository = self::getContainer()->get(DocumentCategoryRepository::class);
$this->em = self::getContainer()->get(EntityManagerInterface::class);
$this->normalizer = self::getContainer()->get(NormalizerInterface::class);
$this->personRender = self::getContainer()->get(PersonRenderInterface::class);
$this->personRepository = self::getContainer()->get(PersonRepository::class);
$this->translatableStringHelper = self::getContainer()->get(TranslatableStringHelperInterface::class);
$this->translator = self::getContainer()->get(TranslatorInterface::class);
$this->thirdPartyRender = self::getContainer()->get(ThirdPartyRender::class);
$this->thirdPartyRepository = self::getContainer()->get(ThirdPartyRepository::class);
}
private function buildContext(): AccompanyingPeriodContext
@@ -127,7 +127,7 @@ class AccompanyingPeriodContextTest extends KernelTestCase
public function provideNormalizedData(): iterable
{
self::bootKernel();
$em = self::$container->get(EntityManagerInterface::class);
$em = self::getContainer()->get(EntityManagerInterface::class);
$thirdParty = $em->createQuery('SELECT t FROM '.ThirdParty::class.' t')
->setMaxResults(1)

View File

@@ -86,18 +86,18 @@ final class PersonContextTest extends KernelTestCase
// prophecy for other dependencies)
$context = $this->buildPersonContext(
null,
self::$container->get(BaseContextData::class),
self::$container->get(CenterResolverManagerInterface::class),
self::$container->get(DocumentCategoryRepository::class),
self::$container->get(EntityManagerInterface::class),
self::$container->get(NormalizerInterface::class),
self::getContainer()->get(BaseContextData::class),
self::getContainer()->get(CenterResolverManagerInterface::class),
self::getContainer()->get(DocumentCategoryRepository::class),
self::getContainer()->get(EntityManagerInterface::class),
self::getContainer()->get(NormalizerInterface::class),
new ParameterBag(['chill_main' => ['acl' => ['form_show_scopes' => false]]]),
null,
self::$container->get(Security::class),
self::getContainer()->get(Security::class),
null,
null,
null,
self::$container->get(ThirdPartyRepository::class)
self::getContainer()->get(ThirdPartyRepository::class)
);
$template = new DocGeneratorTemplate();
$template->setName(['fr' => 'test'])->setContext(AccompanyingPeriodContext::class)
@@ -118,7 +118,7 @@ final class PersonContextTest extends KernelTestCase
public function provideNormalizedData(): iterable
{
self::bootKernel();
$em = self::$container->get(EntityManagerInterface::class);
$em = self::getContainer()->get(EntityManagerInterface::class);
$thirdParty = $em->createQuery('SELECT t FROM '.ThirdParty::class.' t')
->setMaxResults(1)
@@ -136,7 +136,7 @@ final class PersonContextTest extends KernelTestCase
throw new \RuntimeException('No confirmed period in database');
}
$category = self::$container->get(DocumentCategoryRepository::class)
$category = self::getContainer()->get(DocumentCategoryRepository::class)
->findAll()[0];
if (null === $category) {

View File

@@ -38,8 +38,8 @@ class AccompanyingPeriodCalendarGenericDocProviderTest extends KernelTestCase
protected function setUp(): void
{
self::bootKernel();
$this->security = self::$container->get(Security::class);
$this->entityManager = self::$container->get(EntityManagerInterface::class);
$this->security = self::getContainer()->get(Security::class);
$this->entityManager = self::getContainer()->get(EntityManagerInterface::class);
}
/**

View File

@@ -32,7 +32,7 @@ class AccompanyingPeriodWorkEvaluationGenericDocProviderTest extends KernelTestC
protected function setUp(): void
{
self::bootKernel();
$this->entityManager = self::$container->get(EntityManagerInterface::class);
$this->entityManager = self::getContainer()->get(EntityManagerInterface::class);
}
/**

View File

@@ -32,8 +32,8 @@ class PersonCalendarGenericDocProviderTest extends KernelTestCase
protected function setUp(): void
{
self::bootKernel();
$this->security = self::$container->get(Security::class);
$this->entityManager = self::$container->get(EntityManagerInterface::class);
$this->security = self::getContainer()->get(Security::class);
$this->entityManager = self::getContainer()->get(EntityManagerInterface::class);
}
/**