$refreshedUser =
new InMemoryUser('foobar', 'baz'
);
$tokenStorage =
$this->
handleEventWithPreviousSession([new NotSupportingUserProvider(true
),
new NotSupportingUserProvider(false
),
new SupportingUserProvider($refreshedUser)]);
$this->
assertNull($tokenStorage->
getToken());
} public function testTokenIsNotDeauthenticatedOnUserChangeIfNotAnInstanceOfAbstractToken() { $tokenStorage =
new TokenStorage();
$refreshedUser =
new InMemoryUser('changed', 'baz'
);
$token =
new CustomToken(new InMemoryUser('original', 'foo'
),
['ROLE_FOO'
]);
$session =
new Session(new MockArraySessionStorage());
$session->
set('_security_context_key',
serialize($token));
$request =
new Request();
$request->
setSession($session);
$request->cookies->
set('MOCKSESSID', true
);
$listener =
new ContextListener($tokenStorage,
[new NotSupportingUserProvider(true
),
new NotSupportingUserProvider(false
),
new SupportingUserProvider($refreshedUser)], 'context_key'
);
$listener(new RequestEvent($this->
createMock(HttpKernelInterface::
class),
$request, HttpKernelInterface::MAIN_REQUEST
));