/**
  * @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();
 }
 /**
  * @test
  */
 public function logoutEmitsLoggedOutSignalBeforeDestroyingSession()
 {
     $this->authenticationProviderManager = $this->getAccessibleMock('TYPO3\\Flow\\Security\\Authentication\\AuthenticationProviderManager', array('emitLoggedOut'), array(), '', FALSE);
     $this->authenticationProviderManager->_set('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->getMock('TYPO3\\Flow\\Security\\Authentication\\TokenInterface', array(), array(), '', FALSE);
     $token->expects($this->any())->method('isAuthenticated')->will($this->returnValue(TRUE));
     $mockContext = $this->getMock('TYPO3\\Flow\\Security\\Context', array(), array(), '', FALSE);
     $mockContext->expects($this->any())->method('getAuthenticationTokens')->will($this->returnValue(array($token)));
     $loggedOutEmitted = FALSE;
     $this->authenticationProviderManager->expects($this->once())->method('emitLoggedOut')->will($this->returnCallback(function () use(&$loggedOutEmitted) {
         $loggedOutEmitted = TRUE;
     }));
     $this->mockSession->expects($this->once())->method('destroy')->will($this->returnCallback(function () use(&$loggedOutEmitted) {
         if (!$loggedOutEmitted) {
             \PHPUnit_Framework_Assert::fail('emitLoggedOut was not called before destroy');
         }
     }));
     $this->authenticationProviderManager->setSecurityContext($mockContext);
     $this->authenticationProviderManager->logout();
 }