public function getRolesReturnsTheAnonymousRoleIfNoTokenIsAuthenticated()
{
$mockAuthenticationManager = $this->createMock(AuthenticationManagerInterface::class);
$mockAuthenticationManager->expects($this->atLeastOnce())->method('isAuthenticated')->will($this->returnValue(false));
$everybodyRole = new Policy\Role('Neos.Flow:Everybody');
$anonymousRole = new Policy\Role('Neos.Flow:Anonymous');
$mockPolicyService = $this->getAccessibleMock(Policy\PolicyService::class, ['getRole']);
$mockPolicyService->expects($this->any())->method('getRole')->will($this->returnValueMap([['Neos.Flow:Anonymous', $anonymousRole], ['Neos.Flow:Everybody', $everybodyRole]]));
$securityContext = $this->getAccessibleMock(Context::class, ['initialize']);
$securityContext->_set('policyService', $mockPolicyService);
$securityContext->_set('authenticationManager', $mockAuthenticationManager);
$result = $securityContext->getRoles();
$this->assertInstanceOf(Policy\Role::class, $result['Neos.Flow:Anonymous']);
$this->assertEquals('Neos.Flow:Anonymous', (string) $result['Neos.Flow:Anonymous']);
}