mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-29 10:05:03 +00:00
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:
@@ -51,7 +51,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase
|
||||
public function dataGenerateNewAccompanyingCourse()
|
||||
{
|
||||
self::bootKernel();
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
$em = self::getContainer()->get(EntityManagerInterface::class);
|
||||
|
||||
$period = new AccompanyingPeriod(new \DateTime('1 week ago'));
|
||||
$user = $em->getRepository(User::class)
|
||||
@@ -99,7 +99,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase
|
||||
$maxResults = $maxGenerated * 8;
|
||||
|
||||
self::bootKernel();
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
$em = self::getContainer()->get(EntityManagerInterface::class);
|
||||
$center = $em->getRepository(Center::class)
|
||||
->findOneBy(['name' => 'Center A']);
|
||||
|
||||
@@ -166,7 +166,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase
|
||||
$maxResults = $maxGenerated * 8;
|
||||
|
||||
self::bootKernel();
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
$em = self::getContainer()->get(EntityManagerInterface::class);
|
||||
$center = $em->getRepository(Center::class)
|
||||
->findOneBy(['name' => 'Center A']);
|
||||
$qb = $em->createQueryBuilder();
|
||||
@@ -230,7 +230,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase
|
||||
$maxResults = 100;
|
||||
|
||||
self::bootKernel();
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
$em = self::getContainer()->get(EntityManagerInterface::class);
|
||||
$center = $em->getRepository(Center::class)
|
||||
->findOneBy(['name' => 'Center A']);
|
||||
$qb = $em->createQueryBuilder();
|
||||
@@ -433,10 +433,10 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase
|
||||
public function testAccompanyingPeriodPatch(int $personId, int $periodId)
|
||||
{
|
||||
$this->markTestIncomplete('fix test with validation');
|
||||
$period = self::$container->get(AccompanyingPeriodRepository::class)
|
||||
$period = self::getContainer()->get(AccompanyingPeriodRepository::class)
|
||||
->find($periodId);
|
||||
$initialValueEmergency = $period->isEmergency();
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
$em = self::getContainer()->get(EntityManagerInterface::class);
|
||||
|
||||
$this->client->request(
|
||||
Request::METHOD_PATCH,
|
||||
@@ -469,7 +469,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase
|
||||
public function testCommentWithValidData(AccompanyingPeriod $period, mixed $personId, mixed $thirdPartyId)
|
||||
{
|
||||
$this->markTestIncomplete('fix test with validation');
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
$em = self::getContainer()->get(EntityManagerInterface::class);
|
||||
|
||||
$this->client->request(
|
||||
Request::METHOD_POST,
|
||||
@@ -545,7 +545,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase
|
||||
public function testRequestorWithValidData(AccompanyingPeriod $period, mixed $personId, mixed $thirdPartyId)
|
||||
{
|
||||
$this->markTestIncomplete('fix test with validation');
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
$em = self::getContainer()->get(EntityManagerInterface::class);
|
||||
|
||||
// post a person
|
||||
$this->client->request(
|
||||
@@ -626,7 +626,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase
|
||||
public function testResourceWithValidData(AccompanyingPeriod $period, mixed $personId, mixed $thirdPartyId)
|
||||
{
|
||||
$this->markTestIncomplete('fix test with validation');
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
$em = self::getContainer()->get(EntityManagerInterface::class);
|
||||
|
||||
// post a person
|
||||
$this->client->request(
|
||||
|
@@ -44,7 +44,7 @@ final class AccompanyingCourseControllerTest extends WebTestCase
|
||||
public function dataGenerateRandomUsers(): \Iterator
|
||||
{
|
||||
self::bootKernel();
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
$em = self::getContainer()->get(EntityManagerInterface::class);
|
||||
|
||||
$period = new AccompanyingPeriod(new \DateTime('1 week ago'));
|
||||
$user = $em->getRepository(User::class)
|
||||
@@ -96,7 +96,7 @@ final class AccompanyingCourseControllerTest extends WebTestCase
|
||||
$this->assertEquals(1, \preg_match('|^\\/[^\\/]+\\/parcours/([\\d]+)/edit$|', (string) $location, $matches));
|
||||
$id = $matches[1];
|
||||
|
||||
$period = self::$container->get(EntityManagerInterface::class)
|
||||
$period = self::getContainer()->get(EntityManagerInterface::class)
|
||||
->getRepository(AccompanyingPeriod::class)
|
||||
->find($id);
|
||||
|
||||
|
@@ -37,7 +37,7 @@ final class HouseholdApiControllerTest extends WebTestCase
|
||||
{
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
$em = self::getContainer()->get(EntityManagerInterface::class);
|
||||
|
||||
foreach ($this->toDelete as [$class, $id]) {
|
||||
$obj = $em->getRepository($class)->find($id);
|
||||
@@ -52,7 +52,7 @@ final class HouseholdApiControllerTest extends WebTestCase
|
||||
public function generateHouseholdAssociatedWithAddressReference()
|
||||
{
|
||||
self::bootKernel();
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
$em = self::getContainer()->get(EntityManagerInterface::class);
|
||||
$centerA = $em->getRepository(Center::class)->findOneBy(['name' => 'Center A']);
|
||||
$nbReference = $em->createQueryBuilder()->select('count(ar)')->from(AddressReference::class, 'ar')
|
||||
->getQuery()->getSingleScalarResult();
|
||||
@@ -96,7 +96,7 @@ final class HouseholdApiControllerTest extends WebTestCase
|
||||
{
|
||||
self::bootKernel();
|
||||
|
||||
$qb = self::$container->get(EntityManagerInterface::class)
|
||||
$qb = self::getContainer()->get(EntityManagerInterface::class)
|
||||
->createQueryBuilder();
|
||||
|
||||
$householdIds = $qb
|
||||
@@ -128,7 +128,7 @@ final class HouseholdApiControllerTest extends WebTestCase
|
||||
{
|
||||
self::bootKernel();
|
||||
|
||||
$qb = self::$container->get(EntityManagerInterface::class)
|
||||
$qb = self::getContainer()->get(EntityManagerInterface::class)
|
||||
->createQueryBuilder();
|
||||
|
||||
$personIds = $qb
|
||||
|
@@ -42,7 +42,7 @@ final class HouseholdControllerTest extends WebTestCase
|
||||
public function generateValidHouseholdIds()
|
||||
{
|
||||
self::bootKernel();
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
$em = self::getContainer()->get(EntityManagerInterface::class);
|
||||
|
||||
$ids = $em->createQuery(
|
||||
sprintf('SELECT DISTINCT h.id FROM %s h JOIN h.members m JOIN m.person p JOIN p.centerHistory ch JOIN ch.center c WHERE c.name = :center AND ch.endDate IS NULL', Household::class)
|
||||
|
@@ -33,7 +33,7 @@ final class HouseholdMemberControllerTest extends WebTestCase
|
||||
public function provideValidDataEditMember(): \Iterator
|
||||
{
|
||||
self::bootKernel();
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
$em = self::getContainer()->get(EntityManagerInterface::class);
|
||||
|
||||
$membershipIds = $em->createQuery(sprintf('SELECT m.id FROM %s m JOIN m.person p JOIN p.centerHistory ch JOIN ch.center c WHERE c.name = :center AND m.endDate IS NULL AND ch.endDate IS NULL', HouseholdMember::class))
|
||||
->setParameter('center', 'Center A')
|
||||
@@ -51,7 +51,7 @@ final class HouseholdMemberControllerTest extends WebTestCase
|
||||
public function provideValidDataMove(): \Iterator
|
||||
{
|
||||
self::bootKernel();
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
$em = self::getContainer()->get(EntityManagerInterface::class);
|
||||
$yesterday = new \DateTimeImmutable('yesterday');
|
||||
|
||||
$personIds = $em->createQuery(
|
||||
@@ -79,7 +79,7 @@ final class HouseholdMemberControllerTest extends WebTestCase
|
||||
|
||||
do {
|
||||
$id = \array_pop($personIds)['id'];
|
||||
$person = self::$container->get(EntityManagerInterface::class)
|
||||
$person = self::getContainer()->get(EntityManagerInterface::class)
|
||||
->getRepository(Person::class)
|
||||
->find($id);
|
||||
|
||||
|
@@ -29,7 +29,7 @@ final class PersonApiControllerTest extends WebTestCase
|
||||
public function dataGetPersonFromCenterA(): \Iterator
|
||||
{
|
||||
self::bootKernel();
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
$em = self::getContainer()->get(EntityManagerInterface::class);
|
||||
$personIds = $em->createQuery(sprintf(
|
||||
'SELECT p.id FROM %s p JOIN p.centerCurrent pc JOIN pc.center c WHERE c.name = :center',
|
||||
Person::class
|
||||
@@ -52,7 +52,7 @@ final class PersonApiControllerTest extends WebTestCase
|
||||
public function dataGetPersonFromCenterB(): \Iterator
|
||||
{
|
||||
self::bootKernel();
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
$em = self::getContainer()->get(EntityManagerInterface::class);
|
||||
$personIds = $em->createQuery(
|
||||
sprintf('SELECT p.id FROM %s p JOIN p.centerCurrent pc JOIN pc.center c WHERE c.name = :center', Person::class)
|
||||
)
|
||||
|
@@ -47,7 +47,7 @@ final class PersonControllerCreateTest extends WebTestCase
|
||||
public static function tearDownAfterClass(): void
|
||||
{
|
||||
self::bootKernel();
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
$em = self::getContainer()->get(EntityManagerInterface::class);
|
||||
|
||||
// remove two people created during test
|
||||
$jesus = $em->getRepository(\Chill\PersonBundle\Entity\Person::class)
|
||||
|
@@ -54,7 +54,7 @@ final class PersonControllerUpdateTest extends WebTestCase
|
||||
{
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
$em = self::getContainer()->get(EntityManagerInterface::class);
|
||||
|
||||
foreach (self::$toDelete as [$class, $id]) {
|
||||
$entity = $em->find($class, $id);
|
||||
@@ -124,7 +124,7 @@ final class PersonControllerUpdateTest extends WebTestCase
|
||||
|
||||
self::assertResponseRedirects($this->makeViewPath($personId));
|
||||
|
||||
$person = self::$container->get(PersonRepository::class)->find($personId);
|
||||
$person = self::getContainer()->get(PersonRepository::class)->find($personId);
|
||||
|
||||
self::assertEquals('tagada', $person->getFirstName());
|
||||
}
|
||||
@@ -156,8 +156,8 @@ final class PersonControllerUpdateTest extends WebTestCase
|
||||
public static function providePerson(): iterable
|
||||
{
|
||||
self::bootKernel();
|
||||
$centerRepository = self::$container->get(CenterRepositoryInterface::class);
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
$centerRepository = self::getContainer()->get(CenterRepositoryInterface::class);
|
||||
$em = self::getContainer()->get(EntityManagerInterface::class);
|
||||
$center = $centerRepository->findOneBy(['name' => 'Center A']);
|
||||
|
||||
$person = new Person();
|
||||
|
@@ -40,7 +40,7 @@ final class PersonControllerViewTest extends WebTestCase
|
||||
{
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
$em = self::getContainer()->get(EntityManagerInterface::class);
|
||||
|
||||
foreach (self::$toDelete as [$class, $id]) {
|
||||
$entity = $em->find($class, $id);
|
||||
@@ -95,8 +95,8 @@ final class PersonControllerViewTest extends WebTestCase
|
||||
public static function providePerson(): iterable
|
||||
{
|
||||
self::bootKernel();
|
||||
$centerRepository = self::$container->get(CenterRepositoryInterface::class);
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
$centerRepository = self::getContainer()->get(CenterRepositoryInterface::class);
|
||||
$em = self::getContainer()->get(EntityManagerInterface::class);
|
||||
$center = $centerRepository->findOneBy(['name' => 'Center A']);
|
||||
|
||||
$person = new Person();
|
||||
|
@@ -28,9 +28,9 @@ final class PersonDuplicateControllerViewTest extends WebTestCase
|
||||
self::bootKernel();
|
||||
|
||||
/** @var EntityManagerInterface $em */
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
$em = self::getContainer()->get(EntityManagerInterface::class);
|
||||
/** @var CenterRepositoryInterface $centerRepository */
|
||||
$centerRepository = self::$container->get(CenterRepositoryInterface::class);
|
||||
$centerRepository = self::getContainer()->get(CenterRepositoryInterface::class);
|
||||
|
||||
$center = $centerRepository->findOneBy(['name' => 'Center A']);
|
||||
$person = (new Person())
|
||||
|
@@ -43,7 +43,7 @@ final class RelationshipApiControllerTest extends WebTestCase
|
||||
public function personProvider(): array
|
||||
{
|
||||
self::bootKernel();
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
$em = self::getContainer()->get(EntityManagerInterface::class);
|
||||
$personIdHavingRelation = $em->createQueryBuilder()
|
||||
->select('p.id')
|
||||
->from(Person::class, 'p')
|
||||
@@ -78,7 +78,7 @@ final class RelationshipApiControllerTest extends WebTestCase
|
||||
public function relationProvider(): array
|
||||
{
|
||||
self::bootKernel();
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
$em = self::getContainer()->get(EntityManagerInterface::class);
|
||||
$personIdWithoutRelations = $em->createQueryBuilder()
|
||||
->select('p.id')
|
||||
->from(Person::class, 'p')
|
||||
|
@@ -38,7 +38,7 @@ final class SocialWorkEvaluationApiControllerTest extends WebTestCase
|
||||
|
||||
self::bootKernel();
|
||||
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
$em = self::getContainer()->get(EntityManagerInterface::class);
|
||||
$evaluation = $em->find(Evaluation::class, $this->evaluationToReset->getId());
|
||||
|
||||
$evaluation->setActive(true);
|
||||
@@ -49,7 +49,7 @@ final class SocialWorkEvaluationApiControllerTest extends WebTestCase
|
||||
{
|
||||
self::bootKernel();
|
||||
|
||||
$this->em = self::$container->get(EntityManagerInterface::class);
|
||||
$this->em = self::getContainer()->get(EntityManagerInterface::class);
|
||||
|
||||
/** @var SocialAction $socialAction */
|
||||
$socialAction = $this->em->createQuery(
|
||||
|
Reference in New Issue
Block a user