本文整理汇总了PHP中JUser::authorize方法的典型用法代码示例。如果您正苦于以下问题:PHP JUser::authorize方法的具体用法?PHP JUser::authorize怎么用?PHP JUser::authorize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JUser
的用法示例。
在下文中一共展示了JUser::authorize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testAuthorize
/**
* Testing authorize().
*
* @param int User id of user to test
* @param string Action to get aithorized for this user
* @param string Asset to get authorization for
* @param bool Expected return from the authorization check
*
* @return void
*/
public function testAuthorize( )
{
// Set up user 99 to be root_user from configuration
$testConfig = $this->getMock('JConfig', array('get'));
$testConfig->expects(
$this->any())
->method('get')
->will($this->returnValue('test_root_user'));
JFactory::$config = $testConfig;
$user = new JUser(99);
$user->username = 'test_root_user';
$this->assertThat(
$user->authorize('core.admin', 'root.1'),
$this->equalTo(true),
"Emergency root user should have core.admin for root.1"
);
}