public function getAccountReturnsTheAccountAttachedToTheFirstAuthenticatedToken()
{
$mockAuthenticationManager = $this->createMock(AuthenticationManagerInterface::class);
$mockAccount = $this->createMock(Account::class);
$token1 = $this->createMock(TokenInterface::class, [], [], 'token1' . md5(uniqid(mt_rand(), true)));
$token1->expects($this->any())->method('isAuthenticated')->will($this->returnValue(false));
$token1->expects($this->never())->method('getAccount');
$token2 = $this->createMock(TokenInterface::class, [], [], 'token2' . md5(uniqid(mt_rand(), true)));
$token2->expects($this->any())->method('isAuthenticated')->will($this->returnValue(true));
$token2->expects($this->once())->method('getAccount')->will($this->returnValue($mockAccount));
$token3 = $this->createMock(TokenInterface::class, [], [], 'token3' . md5(uniqid(mt_rand(), true)));
$token3->expects($this->any())->method('isAuthenticated')->will($this->returnValue(true));
$token3->expects($this->never())->method('getAccount');
$securityContext = $this->getAccessibleMock(Context::class, ['getAuthenticationTokens']);
$securityContext->setRequest($this->mockActionRequest);
$securityContext->_set('authenticationManager', $mockAuthenticationManager);
$securityContext->expects($this->once())->method('getAuthenticationTokens')->will($this->returnValue([$token1, $token2, $token3]));
$this->assertEquals($mockAccount, $securityContext->getAccount());
}