本文整理匯總了PHP中UserGroup::add方法的典型用法代碼示例。如果您正苦於以下問題:PHP UserGroup::add方法的具體用法?PHP UserGroup::add怎麽用?PHP UserGroup::add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類UserGroup
的用法示例。
在下文中一共展示了UserGroup::add方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testGroup
public function testGroup()
{
$group = new UserGroup('Webmasters');
$group->save();
$group->grant('someGrant');
$this->assertFalse(Acl::isAllowed('dvorak', 'someGrant'));
$group->add('dvorak');
$this->assertTrue(Acl::isAllowed('dvorak', 'someGrant'));
$group = new UserGroup('BadGroup');
$group->save();
$group->revoke('someGrant');
$group->add('dvorak');
$this->assertTrue(Acl::isAllowed('dvorak', 'someGrant')); // Even if dvorak is in a group that has no right he is allowed
}
示例2: insert
protected function insert()
{
parent::insert();
$group = new UserGroup('__'.$this->username);
$group->save();
$group->add($this->username);
return $this->lockKey;
}
示例3: testAddMemberTwice
public function testAddMemberTwice()
{
$group = new UserGroup('SomeName');
$group->save();
$group->add('dvorak');
try
{
$group->add('dvorak');
$this->fail('Expected exception');
}
catch (Exception $e)
{
$this->assertEquals('User is already member of group', $e->getMessage());
}
}