mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-05 22:35:01 +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:
@@ -35,7 +35,7 @@ final class AddressControllerTest extends \Symfony\Bundle\FrameworkBundle\Test\W
|
||||
public function generateAddressIds(): iterable
|
||||
{
|
||||
self::bootKernel();
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
$em = self::getContainer()->get(EntityManagerInterface::class);
|
||||
|
||||
$qb = $em->createQueryBuilder();
|
||||
$addresses = $qb->select('a')->from(Address::class, 'a')
|
||||
|
@@ -29,7 +29,7 @@ final class AddressReferenceApiControllerTest extends WebTestCase
|
||||
{
|
||||
self::bootKernel();
|
||||
/** @var EntityManagerInterface $em */
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
$em = self::getContainer()->get(EntityManagerInterface::class);
|
||||
|
||||
$postalCode = $em->createQueryBuilder()
|
||||
->select('pc')
|
||||
|
@@ -46,7 +46,7 @@ class AddressToReferenceMatcherControllerTest extends WebTestCase
|
||||
|
||||
$this->assertResponseIsSuccessful();
|
||||
|
||||
$this->addressRepository = self::$container->get(AddressRepository::class);
|
||||
$this->addressRepository = self::getContainer()->get(AddressRepository::class);
|
||||
$address = $this->addressRepository->find($addressId);
|
||||
|
||||
$this->assertEquals(Address::ADDR_REFERENCE_STATUS_REVIEWED, $address->getRefStatus());
|
||||
@@ -63,7 +63,7 @@ class AddressToReferenceMatcherControllerTest extends WebTestCase
|
||||
|
||||
$this->assertResponseIsSuccessful();
|
||||
|
||||
$this->addressRepository = self::$container->get(AddressRepository::class);
|
||||
$this->addressRepository = self::getContainer()->get(AddressRepository::class);
|
||||
$address = $this->addressRepository->find($addressId);
|
||||
|
||||
$this->assertEquals(Address::ADDR_REFERENCE_STATUS_MATCH, $address->getRefStatus());
|
||||
@@ -75,7 +75,7 @@ class AddressToReferenceMatcherControllerTest extends WebTestCase
|
||||
public static function addressToReviewProvider(): iterable
|
||||
{
|
||||
self::bootKernel();
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
$em = self::getContainer()->get(EntityManagerInterface::class);
|
||||
|
||||
$nb = $em->createQuery('SELECT count(a) FROM '.Address::class.' a')
|
||||
->getSingleScalarResult();
|
||||
@@ -101,7 +101,7 @@ class AddressToReferenceMatcherControllerTest extends WebTestCase
|
||||
public static function addressUnsyncedProvider(): iterable
|
||||
{
|
||||
self::bootKernel();
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
$em = self::getContainer()->get(EntityManagerInterface::class);
|
||||
|
||||
$nb = $em->createQuery('SELECT count(a) FROM '.AddressReference::class.' a')
|
||||
->getSingleScalarResult();
|
||||
|
@@ -40,7 +40,7 @@ class GeographicalUnitByAddressApiControllerTest extends WebTestCase
|
||||
public static function generateRandomAddress(): iterable
|
||||
{
|
||||
self::bootKernel();
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
$em = self::getContainer()->get(EntityManagerInterface::class);
|
||||
|
||||
$nb = $em->createQuery('SELECT COUNT(a) FROM '.Address::class.' a')->getSingleScalarResult();
|
||||
/** @var \Chill\MainBundle\Entity\Address $random */
|
||||
|
@@ -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));
|
||||
|
||||
|
@@ -46,11 +46,11 @@ final class UserControllerTest extends WebTestCase
|
||||
public function dataGenerateUserId()
|
||||
{
|
||||
self::bootKernel();
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
$em = self::getContainer()->get(EntityManagerInterface::class);
|
||||
|
||||
$user = new User();
|
||||
$user->setUsername('Test_user '.uniqid());
|
||||
$user->setPassword(self::$container->get(UserPasswordEncoderInterface::class)->encodePassword(
|
||||
$user->setPassword(self::getContainer()->get(UserPasswordEncoderInterface::class)->encodePassword(
|
||||
$user,
|
||||
'password'
|
||||
));
|
||||
@@ -157,10 +157,10 @@ final class UserControllerTest extends WebTestCase
|
||||
protected function isPasswordValid($username, $password)
|
||||
{
|
||||
/** @var \Symfony\Component\Security\Core\Encoder\UserPasswordEncoder $passwordEncoder */
|
||||
$passwordEncoder = self::$container
|
||||
$passwordEncoder = self::getContainer()
|
||||
->get(UserPasswordEncoderInterface::class);
|
||||
|
||||
$user = self::$container->get(UserRepositoryInterface::class)
|
||||
$user = self::getContainer()->get(UserRepositoryInterface::class)
|
||||
->findOneBy(['username' => $username]);
|
||||
|
||||
$this->assertTrue($passwordEncoder->isPasswordValid($user, $password));
|
||||
|
Reference in New Issue
Block a user