setAssertion() public méthode

Set an assertion
public setAssertion ( string | Rbac\Permission\PermissionInterface $permission, string | callable | ZfcRbac\Assertion\AssertionInterface $assertion ) : void
$permission string | Rbac\Permission\PermissionInterface
$assertion string | callable | ZfcRbac\Assertion\AssertionInterface
Résultat void
 public function testAssertionMap()
 {
     $rbac = $this->getMock('Rbac\\Rbac', [], [], '', false);
     $roleService = $this->getMock('ZfcRbac\\Service\\RoleService', [], [], '', false);
     $assertionPluginManager = $this->getMock('ZfcRbac\\Assertion\\AssertionPluginManager', [], [], '', false);
     $authorizationService = new AuthorizationService($rbac, $roleService, $assertionPluginManager);
     $authorizationService->setAssertions(['foo' => 'bar', 'bar' => 'foo']);
     $this->assertTrue($authorizationService->hasAssertion('foo'));
     $this->assertTrue($authorizationService->hasAssertion('bar'));
     $authorizationService->setAssertion('bar', null);
     $this->assertFalse($authorizationService->hasAssertion('bar'));
 }
 public function testThrowExceptionForInvalidAssertionCondition()
 {
     $role = $this->getMock('Rbac\\Role\\RoleInterface');
     $rbac = $this->getMock('Rbac\\Rbac', [], [], '', false);
     $rbac->expects($this->once())->method('isGranted')->will($this->returnValue(true));
     $roleService = $this->getMock('ZfcRbac\\Service\\RoleService', [], [], '', false);
     $roleService->expects($this->once())->method('getIdentityRoles')->will($this->returnValue([$role]));
     $assertionPluginManager = $this->getMock('ZfcRbac\\Assertion\\AssertionPluginManager', [], [], '', false);
     $authorizationService = new AuthorizationService($rbac, $roleService, $assertionPluginManager);
     $this->setExpectedException('ZfcRbac\\Exception\\InvalidArgumentException');
     $authorizationService->setAssertion('foo', ['assertions' => 'bar', 'condition' => new \stdClass()]);
     $authorizationService->isGranted('foo');
 }