/** * @expectedException RuntimeException */ public function testWithNonAuthenticationCredentialsNotFoundException() { $securityContext = $this->getMock('Symfony\\Component\\Security\\Core\\SecurityContextInterface'); $securityContext->expects($this->any())->method('isGranted')->will($this->throwException(new \RunTimeException('FAIL'))); $handler = new AclSecurityHandler($securityContext); $this->assertFalse($handler->isGranted('raise exception')); }
/** * @expectedException RuntimeException */ public function testWithNonAuthenticationCredentialsNotFoundException() { $admin = $this->getMock('Sonata\\AdminBundle\\Admin\\AdminInterface'); $securityContext = $this->getMock('Symfony\\Component\\Security\\Core\\SecurityContextInterface'); $securityContext->expects($this->any())->method('isGranted')->will($this->throwException(new \RunTimeException('FAIL'))); $aclProvider = $this->getMock('Symfony\\Component\\Security\\Acl\\Model\\MutableAclProviderInterface'); $handler = new AclSecurityHandler($securityContext, $aclProvider, 'Sonata\\AdminBundle\\Security\\Acl\\Permission\\MaskBuilder', array()); $this->assertFalse($handler->isGranted($admin, 'raise exception', $admin)); }
public function testAcl() { $securityContext = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface'); $securityContext->expects($this->any()) ->method('isGranted') ->will($this->returnValue(true)); $handler = new AclSecurityHandler($securityContext); $this->assertTrue($handler->isGranted(array('TOTO'))); $this->assertTrue($handler->isGranted('TOTO')); $securityContext = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface'); $securityContext->expects($this->any()) ->method('isGranted') ->will($this->returnValue(false)); $handler = new AclSecurityHandler($securityContext); $this->assertFalse($handler->isGranted(array('TOTO'))); $this->assertFalse($handler->isGranted('TOTO')); }