本文整理匯總了PHP中sfGuardUser::hasGroup方法的典型用法代碼示例。如果您正苦於以下問題:PHP sfGuardUser::hasGroup方法的具體用法?PHP sfGuardUser::hasGroup怎麽用?PHP sfGuardUser::hasGroup使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sfGuardUser
的用法示例。
在下文中一共展示了sfGuardUser::hasGroup方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: Doe
$t->diag('output functions');
$t->is((string) $activeUser, 'John Doe (active_user)', '->__toString() returns the full name and the username');
$t->is($activeUser->getName(), 'John Doe', '->getName() returns the full name of the user');
// group managment
$t->diag('group managment');
$t->is($activeUser->getGroupNames(), array(), '->getGroupNames() return empty array if no group is set');
try {
$activeUser->addGroupByName('test-group');
$t->fail('->addGroupByName() does throw an exception if group not exist');
} catch (Exception $e) {
$t->pass('->addGroupByName() does throw an exception if group not exist');
}
$group = new sfGuardGroup();
$group->name = 'test-group';
$group->save();
$t->is($activeUser->hasGroup('test-group'), false, '->hasGroup() return false if user hasn\'t this group');
try {
$activeUser->addGroupByName('test-group');
$t->pass('->addGroupByName() does not throw an exception if group exist');
} catch (Exception $e) {
$t->diag($e->getMessage());
$t->fail('->addGroupByName() does not throw an exception if group exist');
}
$t->is($activeUser->getGroupNames(), array('test-group'), '->getGroupNames() return array with group names');
$t->is($activeUser->hasGroup('test-group'), true, '->hasGroup() return true if user has this group');
// permission managment
$t->diag('permission managment');
$t->is($activeUser->getPermissionNames(), array(), '->getPermissionNames() return empty array if no permission is set');
try {
$activeUser->addPermissionByName('test-permission');
$t->fail('->addPermissionByName() does throw an exception if group not exist');