/** * Remove an ACL role. This deletes the cascading permissions * * @param UserIdentifier $userIdentifier * @return Role * @throws NoSuchEntityException * @throws \LogicException */ protected function _deleteRole($userIdentifier) { $userType = $userIdentifier->getUserType(); if (!$this->_canRoleBeCreatedForUserType($userType)) { throw new \LogicException("The role with user type '{$userType}' cannot be created or deleted."); } $userId = $userIdentifier->getUserId(); switch ($userType) { case UserIdentifier::USER_TYPE_INTEGRATION: $roleName = $userType . $userId; break; default: throw NoSuchEntityException::singleField('userType', $userType); } $role = $this->_roleFactory->create()->load($roleName, 'role_name'); return $role->delete(); }
/** * @param string $userType * @param int $userId * @dataProvider constructProvider */ public function testConstruct($userType, $userId) { $context = new UserIdentifier($this->_userLocatorMock, $userType, $userId); $this->assertEquals($userId, $context->getUserId()); $this->assertEquals($userType, $context->getUserType()); }