本文整理汇总了PHP中AuthorizationPolicy::getAuthorizedContextObject方法的典型用法代码示例。如果您正苦于以下问题:PHP AuthorizationPolicy::getAuthorizedContextObject方法的具体用法?PHP AuthorizationPolicy::getAuthorizedContextObject怎么用?PHP AuthorizationPolicy::getAuthorizedContextObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AuthorizationPolicy
的用法示例。
在下文中一共展示了AuthorizationPolicy::getAuthorizedContextObject方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testAuthorizationPolicy
/**
* @covers AuthorizationPolicy
*/
public function testAuthorizationPolicy()
{
$policy = new AuthorizationPolicy('some message');
// Test advice.
self::assertTrue($policy->hasAdvice(AUTHORIZATION_ADVICE_DENY_MESSAGE));
self::assertFalse($policy->hasAdvice(AUTHORIZATION_ADVICE_CALL_ON_DENY));
self::assertEquals('some message', $policy->getAdvice(AUTHORIZATION_ADVICE_DENY_MESSAGE));
self::assertNull($policy->getAdvice(AUTHORIZATION_ADVICE_CALL_ON_DENY));
// Test authorized context objects.
self::assertFalse($policy->hasAuthorizedContextObject(ASSOC_TYPE_USER_GROUP));
$someContextObject = new DataObject();
$someContextObject->setData('test1', 'test1');
$policy->addAuthorizedContextObject(ASSOC_TYPE_USER_GROUP, $someContextObject);
self::assertTrue($policy->hasAuthorizedContextObject(ASSOC_TYPE_USER_GROUP));
self::assertEquals($someContextObject, $policy->getAuthorizedContextObject(ASSOC_TYPE_USER_GROUP));
self::assertEquals(array(ASSOC_TYPE_USER_GROUP => $someContextObject), $policy->getAuthorizedContext());
// Test authorized context.
$someOtherContextObject = new DataObject();
$someOtherContextObject->setData('test2', 'test2');
$authorizedContext = array(ASSOC_TYPE_USER_GROUP => $someOtherContextObject);
$policy->setAuthorizedContext($authorizedContext);
self::assertEquals($authorizedContext, $policy->getAuthorizedContext());
// Test default policies.
self::assertTrue($policy->applies());
self::assertEquals(AUTHORIZATION_DENY, $policy->effect());
}