| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?php
- namespace App\Test\Service\Security;
- use App\Entity\Access\Access;
- use App\Service\Security\SwitchUser;
- use Doctrine\Common\Collections\ArrayCollection;
- use PHPUnit\Framework\TestCase;
- class SwitchUserTest extends TestCase
- {
- public function setUp():void
- {
- }
- /**
- * @see SwitchUser::isAllowedToSwitch()
- */
- public function testIsAllowedToSwitch(){
- $childrenMockMock = $this->getMockBuilder(Access::class)->getMock();
- $children = new ArrayCollection();
- $children->add($childrenMockMock);
- $userMockMock = $this->getMockBuilder(Access::class)->getMock();
- $userMockMock
- ->expects($this->once())
- ->method('getChildren')
- ->willReturn($children);
- $switchUser = new SwitchUser();
- $this->assertTrue($switchUser->isAllowedToSwitch($userMockMock, $childrenMockMock));
- }
- /**
- * @see SwitchUser::isAllowedToSwitch()
- */
- public function testIsNotAllowedToSwitch(){
- $childrenMockMock = $this->getMockBuilder(Access::class)->getMock();
- $userMockMock = $this->getMockBuilder(Access::class)->getMock();
- $userMockMock
- ->expects($this->once())
- ->method('getChildren')
- ->willReturn(new ArrayCollection());
- $switchUser = new SwitchUser();
- $this->assertFalse($switchUser->isAllowedToSwitch($userMockMock, $childrenMockMock));
- }
- }
|