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); }
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); }
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])); }
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)); }
public function testGetAclRoleId() { $roleId = 9; $this->role->expects($this->exactly(2))->method('getId')->will($this->returnValue($roleId)); $this->assertEquals($roleId, $this->locator->getAclRoleId()); }