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

@@ -32,7 +32,7 @@ final class NotificationApiControllerTest extends WebTestCase
protected function tearDown(): void
{
$em = self::$container->get(EntityManagerInterface::class);
$em = self::getContainer()->get(EntityManagerInterface::class);
foreach ($this->toDelete as [$className, $id]) {
$object = $em->find($className, $id);
@@ -45,8 +45,8 @@ final class NotificationApiControllerTest extends WebTestCase
public function generateDataMarkAsRead()
{
self::bootKernel();
$em = self::$container->get(EntityManagerInterface::class);
$userRepository = self::$container->get(UserRepository::class);
$em = self::getContainer()->get(EntityManagerInterface::class);
$userRepository = self::getContainer()->get(UserRepository::class);
$userA = $userRepository->findOneBy(['username' => 'center a_social']);
$userB = $userRepository->findOneBy(['username' => 'center b_social']);
@@ -77,10 +77,10 @@ final class NotificationApiControllerTest extends WebTestCase
$this->assertResponseIsSuccessful('test marking as read');
$em = self::$container->get(EntityManagerInterface::class);
$em = self::getContainer()->get(EntityManagerInterface::class);
/** @var Notification $notification */
$notification = $em->find(Notification::class, $notificationId);
$user = self::$container->get(UserRepository::class)->findOneBy(['username' => 'center a_social']);
$user = self::getContainer()->get(UserRepository::class)->findOneBy(['username' => 'center a_social']);
$this->assertTrue($notification->isReadBy($user));