/**
  * @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 testBuildInformation()
  {
      $informations = array(
          'EDIT' => array('EDIT')
      );

      $securityContext = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface');
      $admin = $this->getMock('Sonata\AdminBundle\Admin\AdminInterface');
      $admin->expects($this->once())
          ->method('getCode')
          ->will($this->returnValue('test'));

      $admin->expects($this->once())
          ->method('getSecurityInformation')
          ->will($this->returnValue($informations));

      $handler = new AclSecurityHandler($securityContext);

      $results = $handler->buildSecurityInformation($admin);

      $this->assertArrayHasKey('ROLE_TEST_EDIT', $results);
  }