本文整理汇总了PHP中UserRole::getRole方法的典型用法代码示例。如果您正苦于以下问题:PHP UserRole::getRole方法的具体用法?PHP UserRole::getRole怎么用?PHP UserRole::getRole使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserRole
的用法示例。
在下文中一共展示了UserRole::getRole方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testPermissionApplication
public function testPermissionApplication()
{
$dbService = za()->getService('DbService');
$this->setupDefaultObjects();
$plainitems = $dbService->getObjects('Issue');
$authService = za()->getService('AuthService');
foreach ($plainitems as $item) {
$authService->grantAccess($item, za()->getUser(), UserRole::getRole(UserRole::ROLE_ADMIN));
}
// $where=array(), $order='id asc', $page=null, $number=null, $auth='')
$items = $dbService->getObjects('Issue', array(), null, null, null, UserRole::PERM_READ);
$this->assertEqual(count($items), count($plainitems));
// $where=array(), $order='id asc', $page=null, $number=null, $auth='')
$items = $dbService->getObjects('Issue', array(), null, null, null, UserRole::PERM_WRITE);
$this->assertEqual(count($items), count($plainitems));
$items = $dbService->getObjects('Issue', array(), null, null, null, UserRole::PERM_ADMIN);
$this->assertEqual(count($items), count($plainitems));
$item = current($items);
$authService->removeAccess($item, za()->getUser());
$items = $dbService->getObjects('Issue', array(), null, null, null, UserRole::PERM_ADMIN);
$this->assertEqual(count($items), count($plainitems) - 1);
}