From 553fb271e42948b6fc4b7b9d8dcdafc7fbceaec8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 4 Apr 2024 22:26:42 +0200 Subject: [PATCH] fix container operations within tests --- .../ListActivitiesByAccompanyingPeriodContextTest.php | 8 ++++---- src/Bundle/ChillMainBundle/Security/RoleProvider.php | 2 +- .../Tests/Controller/NewsItemControllerTest.php | 4 ++-- .../Tests/Controller/NewsItemsHistoryControllerTest.php | 4 ++-- .../Tests/Repository/NewsItemRepositoryTest.php | 2 +- .../WithEvaluationBetweenDatesFilterTest.php | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Tests/Service/DocGenerator/ListActivitiesByAccompanyingPeriodContextTest.php b/src/Bundle/ChillActivityBundle/Tests/Service/DocGenerator/ListActivitiesByAccompanyingPeriodContextTest.php index ff9f30c30..eadb8710c 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Service/DocGenerator/ListActivitiesByAccompanyingPeriodContextTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Service/DocGenerator/ListActivitiesByAccompanyingPeriodContextTest.php @@ -35,9 +35,9 @@ class ListActivitiesByAccompanyingPeriodContextTest extends KernelTestCase protected function setUp(): void { self::bootKernel(); - $this->listActivitiesByAccompanyingPeriodContext = self::$container->get(ListActivitiesByAccompanyingPeriodContext::class); - $this->accompanyingPeriodRepository = self::$container->get(AccompanyingPeriodRepository::class); - $this->userRepository = self::$container->get(UserRepositoryInterface::class); + $this->listActivitiesByAccompanyingPeriodContext = self::getContainer()->get(ListActivitiesByAccompanyingPeriodContext::class); + $this->accompanyingPeriodRepository = self::getContainer()->get(AccompanyingPeriodRepository::class); + $this->userRepository = self::getContainer()->get(UserRepositoryInterface::class); } /** @@ -101,7 +101,7 @@ class ListActivitiesByAccompanyingPeriodContextTest extends KernelTestCase public static function provideAccompanyingPeriod(): array { self::bootKernel(); - $em = self::$container->get(EntityManagerInterface::class); + $em = self::getContainer()->get(EntityManagerInterface::class); if (null === $period = $em->createQuery('SELECT a FROM '.AccompanyingPeriod::class.' a') ->setMaxResults(1) diff --git a/src/Bundle/ChillMainBundle/Security/RoleProvider.php b/src/Bundle/ChillMainBundle/Security/RoleProvider.php index d17b282f3..ff3b8f411 100644 --- a/src/Bundle/ChillMainBundle/Security/RoleProvider.php +++ b/src/Bundle/ChillMainBundle/Security/RoleProvider.php @@ -25,7 +25,7 @@ class RoleProvider /** * @var iterable */ - private iterable $providers + private readonly iterable $providers ) {} public function getRoles(): array diff --git a/src/Bundle/ChillMainBundle/Tests/Controller/NewsItemControllerTest.php b/src/Bundle/ChillMainBundle/Tests/Controller/NewsItemControllerTest.php index 5aa515fd1..3881188e9 100644 --- a/src/Bundle/ChillMainBundle/Tests/Controller/NewsItemControllerTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Controller/NewsItemControllerTest.php @@ -42,7 +42,7 @@ class NewsItemControllerTest extends WebTestCase public static function tearDownAfterClass(): void { self::bootKernel(); - $em = self::$container->get(EntityManagerInterface::class); + $em = self::getContainer()->get(EntityManagerInterface::class); foreach (self::$entitiesToDelete as [$class, $id]) { $entity = $em->find($class, $id); @@ -58,7 +58,7 @@ class NewsItemControllerTest extends WebTestCase public static function generateNewsItemIds(): iterable { self::bootKernel(); - $em = self::$container->get(EntityManagerInterface::class); + $em = self::getContainer()->get(EntityManagerInterface::class); $newsItem = new NewsItem(); $newsItem->setTitle('Lorem Ipsum'); diff --git a/src/Bundle/ChillMainBundle/Tests/Controller/NewsItemsHistoryControllerTest.php b/src/Bundle/ChillMainBundle/Tests/Controller/NewsItemsHistoryControllerTest.php index 19da9ac18..d36fca40c 100644 --- a/src/Bundle/ChillMainBundle/Tests/Controller/NewsItemsHistoryControllerTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Controller/NewsItemsHistoryControllerTest.php @@ -33,7 +33,7 @@ class NewsItemsHistoryControllerTest extends WebTestCase public static function tearDownAfterClass(): void { self::bootKernel(); - $em = self::$container->get(EntityManagerInterface::class); + $em = self::getContainer()->get(EntityManagerInterface::class); foreach (static::$toDelete as [$class, $entity]) { $query = $em->createQuery(sprintf('DELETE FROM %s e WHERE e.id = :id', $class)) @@ -54,7 +54,7 @@ class NewsItemsHistoryControllerTest extends WebTestCase public static function generateNewsItemIds(): iterable { self::bootKernel(); - $em = self::$container->get(EntityManagerInterface::class); + $em = self::getContainer()->get(EntityManagerInterface::class); $news = new NewsItem(); diff --git a/src/Bundle/ChillMainBundle/Tests/Repository/NewsItemRepositoryTest.php b/src/Bundle/ChillMainBundle/Tests/Repository/NewsItemRepositoryTest.php index 7aab97e48..068a7e6fb 100644 --- a/src/Bundle/ChillMainBundle/Tests/Repository/NewsItemRepositoryTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Repository/NewsItemRepositoryTest.php @@ -35,7 +35,7 @@ class NewsItemRepositoryTest extends KernelTestCase protected function setUp(): void { self::bootKernel(); - $this->entityManager = self::$container->get(EntityManagerInterface::class); + $this->entityManager = self::getContainer()->get(EntityManagerInterface::class); } protected function tearDown(): void diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/SocialWorkFilters/WithEvaluationBetweenDatesFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/SocialWorkFilters/WithEvaluationBetweenDatesFilterTest.php index 680eb4cc9..e8d13eb1e 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/SocialWorkFilters/WithEvaluationBetweenDatesFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/SocialWorkFilters/WithEvaluationBetweenDatesFilterTest.php @@ -30,7 +30,7 @@ final class WithEvaluationBetweenDatesFilterTest extends AbstractFilterTest { self::bootKernel(); - $this->filter = self::$container->get(AccompanyingPeriodWorkWithEvaluationBetweenDatesFilter::class); + $this->filter = self::getContainer()->get(AccompanyingPeriodWorkWithEvaluationBetweenDatesFilter::class); } public function getFilter() @@ -52,7 +52,7 @@ final class WithEvaluationBetweenDatesFilterTest extends AbstractFilterTest { self::bootKernel(); - $em = self::$container->get(EntityManagerInterface::class); + $em = self::getContainer()->get(EntityManagerInterface::class); return [ $em->createQueryBuilder()