本文整理汇总了PHP中JAccessRules::allow方法的典型用法代码示例。如果您正苦于以下问题:PHP JAccessRules::allow方法的具体用法?PHP JAccessRules::allow怎么用?PHP JAccessRules::allow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JAccessRules
的用法示例。
在下文中一共展示了JAccessRules::allow方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testAllow
/**
* Tests the JAccessRules::allow method.
*
* @return void
*
* @since 11.1
*/
public function testAllow()
{
$array1 = array('edit' => array(-42 => 1), 'delete' => array(-42 => 0, 2 => 1));
$rules = new JAccessRules($array1);
// Explicit allow.
$this->assertTrue($rules->allow('edit', -42));
// Check string or int works.
$this->assertTrue($rules->allow('edit', '-42'));
// Implicit deny
$this->assertNull($rules->allow('edit', 999));
// Explicit deny
$this->assertFalse($rules->allow('delete', -42));
// This should be true, implicit deny does not win.
$this->assertTrue($rules->allow('edit', array(-42, 999)));
// This should be false, explicit deny wins.
$this->assertFalse($rules->allow('delete', array(-42, 2)));
// This should be null, the action doesn't exist.
$this->assertNull($rules->allow('unknown', array(-42, 2)));
}