public function testListenerSkipIfNoContaoUserOnKernelRequest()
{
$responseEvent = new GetResponseEvent($this->mockKernel(), new Request(), HttpKernelInterface::MASTER_REQUEST);
$token = $this->getMock('Contao\\CoreBundle\\Security\\Authentication\\ContaoToken', [], [], '', false);
$token->expects($this->any())->method('getUser')->willReturn(new User('foo', 'bar'));
/** @var TokenStorageInterface|\PHPUnit_Framework_MockObject_MockObject $tokenStorage */
$tokenStorage = $this->getMock('Symfony\\Component\\Security\\Core\\Authentication\\Token\\Storage\\TokenStorageInterface');
$tokenStorage->expects($this->any())->method('getToken')->willReturn($token);
/** @var UserSessionListener|\PHPUnit_Framework_MockObject_MockObject $listener */
$listener = $this->getMockBuilder('Contao\\CoreBundle\\EventListener\\UserSessionListener')->setConstructorArgs([$this->mockSession(), $this->getMock('Doctrine\\DBAL\\Connection', [], [], '', false), $tokenStorage, new AuthenticationTrustResolver(AnonymousToken::class, RememberMeToken::class)])->setMethods(['isContaoMasterRequest'])->getMock();
$listener->expects($this->any())->method('isContaoMasterRequest')->willReturn(true);
$listener->setContainer($this->mockContainerWithContaoScopes(ContaoCoreBundle::SCOPE_BACKEND));
$listener->onKernelRequest($responseEvent);
}