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


PHP Context::expects方法代码示例

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


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

示例1: setUp

 public function setUp()
 {
     $this->mockSecurityContext = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->getMock();
     $this->mockSecurityContext->expects($this->any())->method('withoutAuthorizationChecks')->will($this->returnCallback(function ($callback) {
         return $callback->__invoke();
     }));
 }
开发者ID:johannessteu,项目名称:neos-development-collection,代码行数:7,代码来源:NodeExportServiceTest.php

示例2: handleSetsRequestInSecurityContext

 /**
  * @test
  */
 public function handleSetsRequestInSecurityContext()
 {
     $this->mockHttpRequest->expects($this->any())->method('getArguments')->will($this->returnValue(array()));
     $this->mockPropertyMapper->expects($this->any())->method('convert')->with('', 'array', $this->mockPropertyMappingConfiguration)->will($this->returnValue(array()));
     $this->mockSecurityContext->expects($this->once())->method('setRequest')->with($this->mockActionRequest);
     $this->dispatchComponent->handle($this->mockComponentContext);
 }
开发者ID:sokunthearith,项目名称:Intern-Project-Week-2,代码行数:10,代码来源:DispatchComponentTest.php

示例3: getUserWorkspaceNameReturnsTheUsersWorkspaceNameIfAUserIsLoggedIn

 /**
  * @test
  */
 public function getUserWorkspaceNameReturnsTheUsersWorkspaceNameIfAUserIsLoggedIn()
 {
     $mockAccount = $this->getMockBuilder('TYPO3\\Flow\\Security\\Account')->disableOriginalConstructor()->getMock();
     $mockAccount->expects($this->atLeastOnce())->method('getAccountIdentifier')->will($this->returnValue('The UserName'));
     $this->mockSecurityContext->expects($this->atLeastOnce())->method('getAccount')->will($this->returnValue($mockAccount));
     $this->assertSame('user-TheUserName', $this->userService->getUserWorkspaceName());
 }
开发者ID:radmiraal,项目名称:neos-development-collection,代码行数:10,代码来源:UserServiceTest.php

示例4: enforcePolicyDoesNotInvokeInterceptorIfAuthorizationChecksAreDisabled

 /**
  * @test
  * @todo adjust when AfterInvocationInterceptor is used again
  */
 public function enforcePolicyDoesNotInvokeInterceptorIfAuthorizationChecksAreDisabled()
 {
     $this->mockAdviceChain->expects($this->once())->method('proceed')->with($this->mockJoinPoint);
     $this->mockJoinPoint->expects($this->once())->method('getAdviceChain')->will($this->returnValue($this->mockAdviceChain));
     $this->mockSecurityContext->expects($this->atLeastOnce())->method('areAuthorizationChecksDisabled')->will($this->returnValue(true));
     $this->mockPolicyEnforcementInterceptor->expects($this->never())->method('invoke');
     $this->policyEnforcementAspect->enforcePolicy($this->mockJoinPoint);
 }
开发者ID:kszyma,项目名称:flow-development-collection,代码行数:12,代码来源:PolicyEnforcementAspectTest.php

示例5: csrfTokenFieldIsRenderedForUnsafeRequests

 /**
  * @test
  */
 public function csrfTokenFieldIsRenderedForUnsafeRequests()
 {
     /** @var FormViewHelper|\PHPUnit_Framework_MockObject_MockObject $viewHelper */
     $viewHelper = $this->getAccessibleMock(\TYPO3\Fluid\ViewHelpers\FormViewHelper::class, null, array(), '', false);
     $this->injectDependenciesIntoViewHelper($viewHelper);
     $this->securityContext->expects($this->any())->method('isInitialized')->will($this->returnValue(true));
     $this->mockAuthenticationManager->expects($this->any())->method('isAuthenticated')->will($this->returnValue(true));
     $this->securityContext->expects($this->atLeastOnce())->method('getCsrfProtectionToken')->will($this->returnValue('CSRFTOKEN'));
     $this->assertEquals('<input type="hidden" name="__csrfToken" value="CSRFTOKEN" />' . chr(10), $viewHelper->_call('renderCsrfTokenField'));
 }
开发者ID:robertlemke,项目名称:flow-development-collection,代码行数:13,代码来源:FormViewHelperTest.php

示例6: isPrivilegeTargetGrantedReturnsTrueIfThereIsNoDenyVoteAndOneGrantVote

 /**
  * @test
  */
 public function isPrivilegeTargetGrantedReturnsTrueIfThereIsNoDenyVoteAndOneGrantVote()
 {
     $mockRole1 = $this->getMockBuilder(\TYPO3\Flow\Security\Policy\Role::class)->disableOriginalConstructor()->getMock();
     $mockRole1->expects($this->any())->method('getPrivilegeForTarget')->will($this->returnValue($this->abstainPrivilege));
     $mockRole2 = $this->getMockBuilder(\TYPO3\Flow\Security\Policy\Role::class)->disableOriginalConstructor()->getMock();
     $mockRole2->expects($this->any())->method('getPrivilegeForTarget')->will($this->returnValue($this->grantPrivilege));
     $mockRole3 = $this->getMockBuilder(\TYPO3\Flow\Security\Policy\Role::class)->disableOriginalConstructor()->getMock();
     $mockRole3->expects($this->any())->method('getPrivilegeForTarget')->will($this->returnValue($this->abstainPrivilege));
     $this->mockSecurityContext->expects($this->any())->method('getRoles')->will($this->returnValue(array($mockRole1, $mockRole2, $mockRole3)));
     $this->assertTrue($this->privilegeManager->isPrivilegeTargetGranted('somePrivilegeTargetIdentifier'));
 }
开发者ID:cerlestes,项目名称:flow-development-collection,代码行数:14,代码来源:PrivilegeManagerTest.php

示例7: logoutRefreshesTokensInSecurityContext

 /**
  * @test
  */
 public function logoutRefreshesTokensInSecurityContext()
 {
     $this->authenticationProviderManager = $this->getAccessibleMock(\TYPO3\Flow\Security\Authentication\AuthenticationProviderManager::class, array('emitLoggedOut'), array(), '', false);
     $this->inject($this->authenticationProviderManager, 'securityContext', $this->mockSecurityContext);
     $this->inject($this->authenticationProviderManager, 'session', $this->mockSession);
     $this->mockSession->expects($this->any())->method('canBeResumed')->will($this->returnValue(true));
     $this->mockSession->expects($this->any())->method('isStarted')->will($this->returnValue(true));
     $token = $this->createMock(\TYPO3\Flow\Security\Authentication\TokenInterface::class);
     $token->expects($this->any())->method('isAuthenticated')->will($this->returnValue(true));
     $this->mockSecurityContext->expects($this->any())->method('getAuthenticationTokens')->will($this->returnValue(array($token)));
     $this->mockSecurityContext->expects($this->once())->method('refreshTokens');
     $this->authenticationProviderManager->logout();
 }
开发者ID:cerlestes,项目名称:flow-development-collection,代码行数:16,代码来源:AuthenticationProviderManagerTest.php

示例8: handleInjectsActionRequestToSecurityContext

 /**
  * @test
  */
 public function handleInjectsActionRequestToSecurityContext()
 {
     $mockWidgetId = 'SomeWidgetId';
     $mockControllerObjectName = 'SomeControllerObjectName';
     $this->mockHttpRequest->expects($this->at(0))->method('hasArgument')->with('__widgetId')->will($this->returnValue(true));
     $this->mockHttpRequest->expects($this->atLeastOnce())->method('getArgument')->with('__widgetId')->will($this->returnValue($mockWidgetId));
     $mockWidgetContext = $this->getMockBuilder(\TYPO3\Fluid\Core\Widget\WidgetContext::class)->getMock();
     $mockWidgetContext->expects($this->atLeastOnce())->method('getControllerObjectName')->will($this->returnValue($mockControllerObjectName));
     $this->mockAjaxWidgetContextHolder->expects($this->atLeastOnce())->method('get')->with($mockWidgetId)->will($this->returnValue($mockWidgetContext));
     $mockActionRequest = $this->getMockBuilder(\TYPO3\Flow\Mvc\ActionRequest::class)->disableOriginalConstructor()->getMock();
     $this->mockObjectManager->expects($this->atLeastOnce())->method('get')->with(\TYPO3\Flow\Mvc\ActionRequest::class)->will($this->returnValue($mockActionRequest));
     $this->mockSecurityContext->expects($this->once())->method('setRequest')->with($mockActionRequest);
     $this->ajaxWidgetComponent->handle($this->mockComponentContext);
 }
开发者ID:cerlestes,项目名称:flow-development-collection,代码行数:17,代码来源:AjaxWidgetComponentTest.php

示例9: array

 /**
  * @test
  */
 public function renderAddsDefaultFieldNamePrefixToTemplateVariableContainerIfNoPrefixIsSpecifiedAndUseParentRequestArgumentIsSet()
 {
     $expectedPrefix = 'parentRequestsPrefix';
     $mockParentRequest = $this->getMock('TYPO3\\Flow\\Mvc\\ActionRequest', array(), array(), '', FALSE);
     $mockParentRequest->expects($this->once())->method('getArgumentNamespace')->will($this->returnValue($expectedPrefix));
     $mockSubRequest = $this->getMock('TYPO3\\Flow\\Mvc\\ActionRequest', array(), array(), '', FALSE);
     $mockSubRequest->expects($this->once())->method('getParentRequest')->will($this->returnValue($mockParentRequest));
     $viewHelper = $this->getAccessibleMock('TYPO3\\Fluid\\ViewHelpers\\FormViewHelper', array('getFormActionUri', 'renderChildren', 'renderHiddenIdentityField', 'renderHiddenReferrerFields', 'addFormFieldNamesToViewHelperVariableContainer', 'removeFormFieldNamesFromViewHelperVariableContainer', 'addEmptyHiddenFieldNamesToViewHelperVariableContainer', 'removeEmptyHiddenFieldNamesFromViewHelperVariableContainer', 'renderEmptyHiddenFields', 'renderTrustedPropertiesField'), array(), '', FALSE);
     $this->arguments['useParentRequest'] = TRUE;
     $this->controllerContext = $this->getMock('TYPO3\\Flow\\Mvc\\Controller\\ControllerContext', array(), array(), '', FALSE);
     $this->controllerContext->expects($this->once())->method('getRequest')->will($this->returnValue($mockSubRequest));
     $this->renderingContext->setControllerContext($this->controllerContext);
     $this->injectDependenciesIntoViewHelper($viewHelper);
     $this->securityContext->expects($this->any())->method('isInitialized')->will($this->returnValue(FALSE));
     $this->viewHelperVariableContainer->expects($this->once())->method('add')->with('TYPO3\\Fluid\\ViewHelpers\\FormViewHelper', 'fieldNamePrefix', $expectedPrefix);
     $viewHelper->render('index');
 }
开发者ID:animaltool,项目名称:webinterface,代码行数:20,代码来源:FormViewHelperTest.php

示例10: dispatchCallsStartAuthenticationOnAllActiveEntryPoints

 /**
  * @test
  */
 public function dispatchCallsStartAuthenticationOnAllActiveEntryPoints()
 {
     $this->mockActionRequest->expects($this->any())->method('isDispatched')->will($this->returnValue(TRUE));
     $mockAuthenticationToken1 = $this->getMockBuilder(\TYPO3\Flow\Security\Authentication\TokenInterface::class)->getMock();
     $mockEntryPoint1 = $this->getMockBuilder(\TYPO3\Flow\Security\Authentication\EntryPointInterface::class)->getMock();
     $mockAuthenticationToken1->expects($this->any())->method('getAuthenticationEntryPoint')->will($this->returnValue($mockEntryPoint1));
     $mockAuthenticationToken2 = $this->getMockBuilder(\TYPO3\Flow\Security\Authentication\TokenInterface::class)->getMock();
     $mockEntryPoint2 = $this->getMockBuilder(\TYPO3\Flow\Security\Authentication\EntryPointInterface::class)->getMock();
     $mockAuthenticationToken2->expects($this->any())->method('getAuthenticationEntryPoint')->will($this->returnValue($mockEntryPoint2));
     $this->mockSecurityContext->expects($this->atLeastOnce())->method('getAuthenticationTokens')->will($this->returnValue(array($mockAuthenticationToken1, $mockAuthenticationToken2)));
     $this->mockFirewall->expects($this->once())->method('blockIllegalRequests')->will($this->throwException(new AuthenticationRequiredException()));
     $mockEntryPoint1->expects($this->once())->method('startAuthentication')->with($this->mockHttpRequest, $this->mockHttpResponse);
     $mockEntryPoint2->expects($this->once())->method('startAuthentication')->with($this->mockHttpRequest, $this->mockHttpResponse);
     try {
         $this->dispatcher->dispatch($this->mockActionRequest, $this->mockHttpResponse);
     } catch (AuthenticationRequiredException $exception) {
     }
 }
开发者ID:nlx-sascha,项目名称:flow-development-collection,代码行数:21,代码来源:DispatcherTest.php

示例11: shutdownCreatesSpecialDataEntryForSessionWithAuthenticatedAccounts

 /**
  * @test
  */
 public function shutdownCreatesSpecialDataEntryForSessionWithAuthenticatedAccounts()
 {
     $session = new Session();
     $this->inject($session, 'bootstrap', $this->mockBootstrap);
     $this->inject($session, 'objectManager', $this->mockObjectManager);
     $this->inject($session, 'settings', $this->settings);
     $this->inject($session, 'metaDataCache', $this->createCache('Meta'));
     $this->inject($session, 'storageCache', $this->createCache('Storage'));
     $session->initializeObject();
     $session->start();
     $account = new Account();
     $account->setAccountIdentifier('admin');
     $account->setAuthenticationProviderName('MyProvider');
     $token = new UsernamePassword();
     $token->setAuthenticationStatus(TokenInterface::AUTHENTICATION_SUCCESSFUL);
     $token->setAccount($account);
     $this->mockSecurityContext->expects($this->any())->method('isInitialized')->will($this->returnValue(TRUE));
     $this->mockSecurityContext->expects($this->any())->method('getAuthenticationTokens')->will($this->returnValue(array($token)));
     $session->close();
     $this->httpRequest->setCookie($this->httpResponse->getCookie('TYPO3_Flow_Session'));
     $session->resume();
     $this->assertEquals(array('MyProvider:admin'), $session->getData('TYPO3_Flow_Security_Accounts'));
 }
开发者ID:animaltool,项目名称:webinterface,代码行数:26,代码来源:SessionTest.php

示例12: initializeSeparatesActiveAndInactiveTokens

 /**
  * @test
  */
 public function initializeSeparatesActiveAndInactiveTokens()
 {
     $this->securityContext->expects($this->once())->method('separateActiveAndInactiveTokens');
     $this->securityContext->initialize();
 }
开发者ID:kszyma,项目名称:flow-development-collection,代码行数:8,代码来源:ContextTest.php

示例13: authenticatingAnUsernamePasswordTokenFetchesAccountWithDisabledAuthorization

 /**
  * @test
  */
 public function authenticatingAnUsernamePasswordTokenFetchesAccountWithDisabledAuthorization()
 {
     $this->mockToken->expects($this->once())->method('getCredentials')->will($this->returnValue(array('username' => 'admin', 'password' => 'password')));
     $this->mockSecurityContext->expects($this->once())->method('withoutAuthorizationChecks');
     $this->persistedUsernamePasswordProvider->authenticate($this->mockToken);
 }
开发者ID:nlx-sascha,项目名称:flow-development-collection,代码行数:9,代码来源:PersistedUsernamePasswordProviderTest.php


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