/**
  * @test
  */
 public function authenticateTagsSessionWithAccountIdentifier()
 {
     $account = new Account();
     $account->setAccountIdentifier('admin');
     $securityContext = $this->getMockBuilder(\TYPO3\Flow\Security\Context::class)->setMethods(array('getAuthenticationStrategy', 'getAuthenticationTokens', 'refreshTokens', 'refreshRoles'))->getMock();
     $token = $this->createMock(\TYPO3\Flow\Security\Authentication\TokenInterface::class);
     $token->expects($this->any())->method('getAccount')->will($this->returnValue($account));
     $token->expects($this->atLeastOnce())->method('isAuthenticated')->will($this->returnValue(true));
     $securityContext->expects($this->atLeastOnce())->method('getAuthenticationTokens')->will($this->returnValue(array($token)));
     $this->mockSession->expects($this->once())->method('addTag')->with('TYPO3-Flow-Security-Account-21232f297a57a5a743894a0e4a801fc3');
     $this->authenticationProviderManager->_set('providers', array());
     $this->authenticationProviderManager->_set('securityContext', $securityContext);
     $this->authenticationProviderManager->authenticate();
 }
 /**
  * @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();
 }