예제 #1
0
 public function testRemovePermissions()
 {
     $integrationId = 22;
     $roleName = UserContextInterface::USER_TYPE_INTEGRATION . $integrationId;
     $this->roleMock->expects($this->once())->method('load')->with($roleName)->will($this->returnSelf());
     $this->integrationAuthorizationService->removePermissions($integrationId);
 }
예제 #2
0
 public function testGrantAllPermissions()
 {
     $rootResource = 'Magento_All:all';
     $this->rootAclResourceMock->expects($this->any())->method('getId')->will($this->returnValue($rootResource));
     $this->roleMock->expects($this->any())->method('getId')->will($this->returnValue(self::ROLE_ID));
     $this->rulesMock->expects($this->any())->method('setRoleId')->with(self::ROLE_ID)->will($this->returnSelf());
     $this->rulesMock->expects($this->any())->method('setResources')->with([$rootResource])->will($this->returnSelf());
     $this->rulesMock->expects($this->any())->method('saveRel')->will($this->returnSelf());
     $this->integrationAuthorizationService->grantAllPermissions(self::INTEGRATION_ID);
 }
예제 #3
0
 public function testAfterSave()
 {
     $roleId = 123;
     $methodUserMock = $this->getMockBuilder('\\Magento\\User\\Model\\User')->disableOriginalConstructor()->setMethods(['hasRoleId', 'getRoleId'])->getMock();
     $methodUserMock->expects($this->once())->method('hasRoleId')->willReturn(true);
     $methodUserMock->expects($this->once())->method('getRoleId')->willReturn($roleId);
     $this->resourceMock->expects($this->atLeastOnce())->method('getConnection')->willReturn($this->dbAdapterMock);
     $this->roleFactoryMock->expects($this->once())->method('create')->willReturn($this->roleMock);
     $this->roleMock->expects($this->once())->method('load')->willReturn($this->roleMock);
     $this->roleMock->expects($this->atLeastOnce())->method('getId')->willReturn($roleId);
     $this->dbAdapterMock->expects($this->once())->method('describeTable')->willReturn([1, 2, 3]);
     $this->assertInstanceOf('\\Magento\\User\\Model\\ResourceModel\\User', $this->invokeMethod($this->model, '_afterSave', [$methodUserMock]));
 }
예제 #4
0
 public function testGetAllowedResourcesByUser()
 {
     $this->roleMock->expects($this->any())->method('getId')->will($this->returnValue(1));
     $expectedResources = ['Magento_Backend::dashboard', 'Magento_Cms::page'];
     $this->assertEquals($expectedResources, $this->aclRetriever->getAllowedResourcesByUser(UserContextInterface::USER_TYPE_INTEGRATION, 1));
 }
예제 #5
0
 public function testGetAclRoleId()
 {
     $roleId = 9;
     $this->role->expects($this->exactly(2))->method('getId')->will($this->returnValue($roleId));
     $this->assertEquals($roleId, $this->locator->getAclRoleId());
 }