本文整理汇总了PHP中UserRole::setId方法的典型用法代码示例。如果您正苦于以下问题:PHP UserRole::setId方法的具体用法?PHP UserRole::setId怎么用?PHP UserRole::setId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserRole
的用法示例。
在下文中一共展示了UserRole::setId方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createUserRole
/**
* @param int $id
* @param string $roleName
* @return UserRole
*/
public static function createUserRole($id, $roleName)
{
$useRole = new UserRole();
$useRole->setId($id);
$useRole->setName($roleName);
return $useRole;
}
示例2: mapDtoToUserRole
public function mapDtoToUserRole(RoleDto $roleDto)
{
$userRole = new UserRole();
$userRole->setId($roleDto->getId());
$userRole->setName($roleDto->getName());
return $userRole;
}
示例3: testGetNonPredefinedUserRoles
/**
* @covers SystemUserService::getNonPredefinedUserRoles
*/
public function testGetNonPredefinedUserRoles()
{
$userRoles = new Doctrine_Collection('UserRole');
for ($i = 0; $i < 2; $i++) {
$userRole = new UserRole();
$userRole->setId($i + 1);
$userRole->setName("test name" . $i + 1);
$userRole->setIsAssignable(1);
$userRole->setIsPredefined(0);
$userRoles->add($userRole);
}
$dao = $this->getMock('SystemUserDao');
$dao->expects($this->once())->method('getNonPredefinedUserRoles')->will($this->returnValue($userRoles));
$this->systemUserService->setSystemUserDao($dao);
$result = $this->systemUserService->getNonPredefinedUserRoles();
$this->assertEquals($userRoles, $result);
}
示例4: testGetScreenPermissions
public function testGetScreenPermissions()
{
$userRole = new UserRole();
$userRole->setId(1);
$userRole->setName('Admin');
$user = new SystemUser();
$user->setId(1);
$user->setEmpNumber(NULL);
$user->setUserRole($userRole);
$systemUserService = $this->getMock('SystemUserService', array('getSystemUser'));
$systemUserService->expects($this->once())->method('getSystemUser')->with($user->getId())->will($this->returnValue($user));
$this->manager->setSystemUserService($systemUserService);
$this->manager->setUser($user);
$mockScreenPermissionService = $this->getMock('ScreenPermissionService', array('getScreenPermissions'));
$permission = new ResourcePermission(true, false, true, false);
$module = 'admin';
$action = 'testAction';
$roles = array($userRole);
$mockScreenPermissionService->expects($this->once())->method('getScreenPermissions')->with($module, $action, $roles)->will($this->returnValue($permission));
$this->manager->setScreenPermissionService($mockScreenPermissionService);
$result = $this->manager->getScreenPermissions($module, $action);
$this->assertEquals($permission, $result);
}
示例5: testGetAccessibleUserRoleIds
public function testGetAccessibleUserRoleIds()
{
$mockService = $this->getMock('SystemUserService');
$roleList = new Doctrine_Collection('SystemUser');
for ($i = 0; $i < 3; $i++) {
$userRole = new UserRole();
$userRole->setId($i + 1);
$userRole->setName('test' . $i + 1);
$roleList->add($userRole);
}
$mockService->expects($this->once())->method('getAssignableUserRoles')->will($this->returnValue($roleList));
$this->adminUserRole->setSystemUserService($mockService);
$roleIds = $this->adminUserRole->getAccessibleUserRoleIds(null, null);
$this->assertEquals($roleIds, array(1, 2, 3));
}