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


PHP TokenInterface::expects方法代码示例

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


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

示例1: testOnSuccessLogin

 /**
  * @dataProvider dataProvider
  *
  * @param UserInterface $user
  * @param bool $expected
  */
 public function testOnSuccessLogin(UserInterface $user, $expected)
 {
     $this->token->expects($this->once())->method('getUser')->willReturn($user);
     $this->event->expects($this->once())->method('getAuthenticationToken')->willReturn($this->token);
     $this->event->expects($expected ? $this->once() : $this->never())->method('getRequest')->willReturn($this->request);
     $this->assertNull($this->request->attributes->get('_fullRedirect'));
     $this->listener->onSecurityInteractiveLogin($this->event);
     $this->assertEquals($expected, $this->request->attributes->get('_fullRedirect'));
 }
开发者ID:adam-paterson,项目名称:orocommerce,代码行数:15,代码来源:LoginListenerTest.php

示例2: taskUserTracker

 /**
  * @test
  */
 public function taskUserTracker()
 {
     $user = new User();
     $task = new Task();
     $this->securityContext->expects($this->once())->method('getToken')->will($this->returnValue($this->token));
     $this->token->expects($this->once())->method('getUser')->will($this->returnValue($user));
     $tracker = new Tracker($user, $task, new \DateTime('now'));
     $this->trackerRepository->expects($this->once())->method('retrieveUserTracker')->with($user)->will($this->returnValue($tracker));
     $result = $this->twigExtension->userTracker();
     $this->assertEquals($tracker, $result);
 }
开发者ID:vdrizheruk,项目名称:OroCrmTimeLapBundle,代码行数:14,代码来源:TimeTrackingExtensionTest.php

示例3: testApplyAnonymous

 /**
  * @covers Kunstmaan\AdminBundle\Helper\Security\Acl\AclNativeHelper::apply
  */
 public function testApplyAnonymous()
 {
     $queryBuilder = new QueryBuilder($this->conn);
     $queryBuilder->add('from', array(array('table' => 'myTable', 'alias' => 'n')));
     $roles = array();
     $this->token->expects($this->once())->method('getRoles')->will($this->returnValue($roles));
     $this->rh->expects($this->once())->method('getReachableRoles')->with($roles)->will($this->returnValue($roles));
     $this->token->expects($this->any())->method('getUser')->will($this->returnValue('anon.'));
     $permissionDef = new PermissionDefinition(array('view'), 'Kunstmaan\\NodeBundle\\Entity\\Node', 'n');
     /* @var $qb QueryBuilder */
     $qb = $this->object->apply($queryBuilder, $permissionDef);
     $query = $qb->getSQL();
     $this->assertContains('"IS_AUTHENTICATED_ANONYMOUSLY"', $query);
 }
开发者ID:axelvnk,项目名称:KunstmaanBundlesCMS,代码行数:17,代码来源:AclNativeHelperTest.php

示例4: handleReturnToken

 /**
  * @test
  */
 public function handleReturnToken()
 {
     $token = new WsseToken();
     $token->setUser('admin');
     $token->setAttribute('digest', 'admin');
     $token->setAttribute('nonce', 'admin');
     $token->setAttribute('created', '2010-12-12 20:00:00');
     $this->tokenMock->expects($this->atLeastOnce())->method('getUser')->will($this->returnValue($this->userMock));
     $this->userMock->expects($this->once())->method('isActive')->will($this->returnValue(true));
     $this->authenticationManager->expects($this->once())->method('authenticate')->with($token)->will($this->returnValue($this->tokenMock));
     /** @noinspection PhpUndefinedMethodInspection */
     $this->securityContext->expects($this->once())->method('setToken')->with($this->tokenMock);
     $this->request->headers->add(array('X-WSSE' => 'UsernameToken Username="admin", PasswordDigest="admin", Nonce="admin", Created="2010-12-12 20:00:00"'));
     $this->wsseListener->handle($this->responseEvent);
 }
开发者ID:gitter-badger,项目名称:diamantedesk-application,代码行数:18,代码来源:WsseListenerTest.php

示例5: testGetAllowedEntityIds

 /**
  * @covers Kunstmaan\AdminBundle\Helper\Security\Acl\AclHelper::getAllowedEntityIds
  * @covers Kunstmaan\AdminBundle\Helper\Security\Acl\AclHelper::getPermittedAclIdsSQLForUser
  */
 public function testGetAllowedEntityIds()
 {
     $roles = array(new Role('ROLE_KING'));
     $allRoles = array($roles[0], new Role('ROLE_SUBJECT'));
     $this->token->expects($this->once())->method('getRoles')->will($this->returnValue($roles));
     $this->rh->expects($this->once())->method('getReachableRoles')->with($roles)->will($this->returnValue($allRoles));
     $user = $this->getMockBuilder('FOS\\UserBundle\\Model\\UserInterface')->getMock();
     $user->expects($this->any())->method('getUsername')->will($this->returnValue('MyUser'));
     $this->token->expects($this->any())->method('getUser')->will($this->returnValue($user));
     $hydrator = $this->getMockBuilder('Doctrine\\ORM\\Internal\\Hydration\\ScalarHydrator')->disableOriginalConstructor()->getMock();
     $rows = array(array('id' => 1), array('id' => 9));
     $hydrator->expects($this->once())->method('hydrateAll')->will($this->returnValue($rows));
     $this->em->expects($this->any())->method('newHydrator')->will($this->returnValue($hydrator));
     /* @var $query NativeQuery */
     $query = new NativeQuery($this->em);
     $this->em->expects($this->once())->method('createNativeQuery')->will($this->returnValue($query));
     $permissionDef = new PermissionDefinition(array('view'), 'Kunstmaan\\NodeBundle\\Entity\\Node', 'n');
     /* @var $result array */
     $result = $this->object->getAllowedEntityIds($permissionDef);
     $this->assertEquals(array(1, 9), $result);
 }
开发者ID:BranchBit,项目名称:KunstmaanBundlesCMS,代码行数:25,代码来源:AclHelperTest.php


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