$request =
new Request();
$request->attributes->
set('_security_firewall_run', '_security_session'
);
$request->
setSession($session);
$requestStack =
new RequestStack();
$requestStack->
push($request);
if (null !==
$original) { $session->
set('_security_session',
$original);
} $factories =
['request_stack' =>
fn () =>
$requestStack];
$tokenStorage =
new UsageTrackingTokenStorage(new TokenStorage(),
new class($factories) implements ContainerInterface
{ use ServiceLocatorTrait;
});
$tokenStorage->
setToken($newToken);
$request->cookies->
set('MOCKSESSID', true
);
$sessionId =
$session->
getId();
$usageIndex =
$session->
getUsageIndex();
$event =
new ResponseEvent(