当前位置: 首页>>代码示例>>PHP>>正文


PHP AuthorizationCheckerInterface::expects方法代码示例

本文整理汇总了PHP中Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP AuthorizationCheckerInterface::expects方法的具体用法?PHP AuthorizationCheckerInterface::expects怎么用?PHP AuthorizationCheckerInterface::expects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface的用法示例。


在下文中一共展示了AuthorizationCheckerInterface::expects方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testLoadWithAlternativeDocumentManager

 /**
  * Test using the block loader with two different document managers.
  */
 public function testLoadWithAlternativeDocumentManager()
 {
     $absoluteBlockPath = '/some/absolute/path';
     $block = $this->getMock('Sonata\\BlockBundle\\Model\\BlockInterface');
     $block->expects($this->any())->method('getName')->will($this->returnValue('the-block'));
     $altBlock = $this->getMock('Sonata\\BlockBundle\\Model\\BlockInterface');
     $altBlock->expects($this->any())->method('getName')->will($this->returnValue('alt-block'));
     $this->dmMock->expects($this->once())->method('find')->with($this->equalTo(null), $this->equalTo($absoluteBlockPath))->will($this->returnValue($block));
     $altDmMock = $this->getMockBuilder('Doctrine\\ODM\\PHPCR\\DocumentManager')->disableOriginalConstructor()->getMock();
     $altDmMock->expects($this->once())->method('find')->with($this->equalTo(null), $this->equalTo($absoluteBlockPath))->will($this->returnValue($altBlock));
     $this->pwcMock->expects($this->at(0))->method('isGranted')->with(PublishWorkflowChecker::VIEW_ATTRIBUTE, $this->equalTo($block))->will($this->returnValue(true));
     $this->pwcMock->expects($this->at(1))->method('isGranted')->with(PublishWorkflowChecker::VIEW_ATTRIBUTE, $this->equalTo($altBlock))->will($this->returnValue(true));
     $registryMock = $this->getMockBuilder('Doctrine\\Bundle\\PHPCRBundle\\ManagerRegistry')->disableOriginalConstructor()->getMock();
     $registryMock->expects($this->at(0))->method('getManager')->with($this->equalTo('themanager'))->will($this->returnValue($this->dmMock));
     $registryMock->expects($this->at(1))->method('getManager')->with($this->equalTo('altmanager'))->will($this->returnValue($altDmMock));
     $blockLoader = new PhpcrBlockLoader($registryMock, $this->pwcMock, $this->requestStackMock, null, 'emptyblocktype');
     $blockLoader->setManagerName('themanager');
     $foundBlock = $blockLoader->load(array('name' => $absoluteBlockPath));
     $this->assertInstanceOf('Sonata\\BlockBundle\\Model\\BlockInterface', $foundBlock);
     $this->assertEquals('the-block', $foundBlock->getName());
     $blockLoader->setManagerName('altmanager');
     $foundBlock = $blockLoader->load(array('name' => $absoluteBlockPath));
     $this->assertInstanceOf('Sonata\\BlockBundle\\Model\\BlockInterface', $foundBlock);
     $this->assertEquals('alt-block', $foundBlock->getName());
 }
开发者ID:symfony-cmf,项目名称:block-bundle,代码行数:28,代码来源:PhpcrBlockLoaderTest.php

示例2: testIsGrantedWithException

 public function testIsGrantedWithException()
 {
     $this->setExpectedException('RuntimeException', 'Something is wrong');
     $this->admin->expects($this->any())->method('getCode')->will($this->returnValue('foo.bar'));
     $this->authorizationChecker->expects($this->any())->method('isGranted')->will($this->returnCallback(function (array $attributes, $object) {
         throw new \RuntimeException('Something is wrong');
     }));
     $handler = $this->getRoleSecurityHandler(array('ROLE_BATMAN'));
     $handler->isGranted($this->admin, 'BAZ');
 }
开发者ID:clavier-souris,项目名称:SonataAdminBundle,代码行数:10,代码来源:RoleSecurityHandlerTest.php

示例3: testOnKernelRequestAccessGranted

 public function testOnKernelRequestAccessGranted()
 {
     $request = new Request();
     $request->attributes->set('siteaccess', new SiteAccess());
     $event = new GetResponseEvent($this->getMock('Symfony\\Component\\HttpKernel\\HttpKernelInterface'), $request, HttpKernelInterface::MASTER_REQUEST);
     $token = $this->getMock('Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface');
     $token->expects($this->any())->method('getUsername')->will($this->returnValue('foo'));
     $this->tokenStorage->expects($this->once())->method('getToken')->will($this->returnValue($token));
     $this->authChecker->expects($this->once())->method('isGranted')->will($this->returnValue(true));
     // Nothing should happen or should be returned.
     $this->listener->onKernelRequest($event);
 }
开发者ID:ezsystems,项目名称:ezpublish-kernel,代码行数:12,代码来源:SecurityListenerTest.php

示例4: testIsGrantedWithVoter

 public function testIsGrantedWithVoter()
 {
     $this->parameterResolver->expects($this->once())->method('resolveVoter')->will($this->returnValue(true));
     $this->authorizationChecker->expects($this->once())->method('isGranted')->with($this->identicalTo('lug.' . ($action = 'show')), $this->identicalTo($object = $this->createStdClassMock()))->will($this->returnValue(true));
     $this->assertTrue($this->securityChecker->isGranted($action, $object));
 }
开发者ID:php-lug,项目名称:lug,代码行数:6,代码来源:SecurityCheckerTest.php


注:本文中的Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface::expects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。