public function logoutEmitsLoggedOutSignalBeforeDestroyingSession()
{
$this->authenticationProviderManager = $this->getAccessibleMock(AuthenticationProviderManager::class, ['emitLoggedOut'], [], '', 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->getMockBuilder(TokenInterface::class)->disableOriginalConstructor()->getMock();
$token->expects($this->any())->method('isAuthenticated')->will($this->returnValue(true));
$this->mockSecurityContext->expects($this->any())->method('getAuthenticationTokens')->will($this->returnValue([$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->logout();
}