Browse Source

fix unit tests

Olivier Massot 2 years ago
parent
commit
5a54d5a49c

+ 1 - 1
src/Security/Voter/EntityVoter/AbstractEntityVoter.php

@@ -54,7 +54,7 @@ abstract class AbstractEntityVoter extends Voter
         protected Security $security,
         protected Utils $accessUtils,
         private InternalRequestsService $internalRequestsService,
-        EntityManagerInterface $em,
+        private EntityManagerInterface $em,
         private SwitchUser $switchUser
     ) {}
 

+ 4 - 4
tests/Unit/Security/Voter/EntityVoter/AbstractEntityVoterTest.php

@@ -65,7 +65,7 @@ class AbstractVoterTest extends TestCase
 {
     protected Security | MockObject $security;
     protected Utils | MockObject $accessUtils;
-    protected EntityManagerInterface | MockObject $entityManager;
+    protected EntityManagerInterface | MockObject $em;
     protected InternalRequestsService | MockObject $internalRequestsService;
     protected SwitchUser | MockObject $switchUserService;
 
@@ -114,7 +114,7 @@ class AbstractVoterTest extends TestCase
         $this->security = $this->getMockBuilder(Security::class)->disableOriginalConstructor()->getMock();
         $this->accessUtils = $this->getMockBuilder(Utils::class)->disableOriginalConstructor()->getMock();
         $this->internalRequestsService = $this->getMockBuilder(InternalRequestsService::class)->disableOriginalConstructor()->getMock();
-        $this->entityManager = $this->getMockBuilder(EntityManagerInterface::class)->disableOriginalConstructor()->getMock();
+        $this->em = $this->getMockBuilder(EntityManagerInterface::class)->disableOriginalConstructor()->getMock();
         $this->switchUserService = $this->getMockBuilder(SwitchUser::class)->disableOriginalConstructor()->getMock();
     }
 
@@ -129,7 +129,7 @@ class AbstractVoterTest extends TestCase
                 $this->security,
                 $this->accessUtils,
                 $this->internalRequestsService,
-                $this->entityManager,
+                $this->em,
                 $this->switchUserService
             ])
             ->setMethodsExcept([$methodName])
@@ -314,7 +314,7 @@ class AbstractVoterTest extends TestCase
         $_SERVER['HTTP_X_SWITCH_USER'] = 1;
 
         $this->security->expects(self::once())->method('getUser')->willReturn($originalUser);
-        $this->entityManager->expects(self::once())->method('find')->with(Access::class, 1)->willReturn($switchUser);
+        $this->em->expects(self::once())->method('find')->with(Access::class, 1)->willReturn($switchUser);
 
         $abstractVoter = $this->makeAbstractVoterMockFor('getUser');