public function testSessionReplacedOnKernelRequest($scope, $userClass, $sessionBagName)
{
$sessionValuesToBeSet = ['foo' => 'bar', 'lonesome' => 'looser'];
$responseEvent = new GetResponseEvent($this->mockKernel(), new Request(), HttpKernelInterface::MASTER_REQUEST);
$session = $this->mockSession();
$user = $this->getMockBuilder($userClass)->setMethods(['__get'])->getMock();
$user->expects($this->any())->method('__get')->with($this->equalTo('session'))->willReturn($sessionValuesToBeSet);
$token = $this->getMock('Contao\\CoreBundle\\Security\\Authentication\\ContaoToken', [], [], '', false);
$token->expects($this->any())->method('getUser')->willReturn($user);
$tokenStorage = $this->getMock('Symfony\\Component\\Security\\Core\\Authentication\\Token\\Storage\\TokenStorageInterface');
$tokenStorage->expects($this->any())->method('getToken')->willReturn($token);
$listener = $this->getListener($session, null, $tokenStorage);
$listener->setContainer($this->mockContainerWithContaoScopes($scope));
$listener->onKernelRequest($responseEvent);
/** @var AttributeBagInterface $bag */
$bag = $session->getBag($sessionBagName);
$this->assertSame($sessionValuesToBeSet, $bag->all());
}