Contao\CoreBundle\Test\EventListener\UserSessionListenerTest::testListenerSkipIfNoUserOnKernelResponse PHP Méthode

testListenerSkipIfNoUserOnKernelResponse() public méthode

Tests that neither the session bag nor doctrine is requested when there is no user.
public testListenerSkipIfNoUserOnKernelResponse ( AnonymousToken $noUserReturn = null )
$noUserReturn Symfony\Component\Security\Core\Authentication\Token\AnonymousToken
    public function testListenerSkipIfNoUserOnKernelResponse(AnonymousToken $noUserReturn = null)
    {
        $responseEvent = new FilterResponseEvent($this->mockKernel(), new Request(), HttpKernelInterface::MASTER_REQUEST, new Response());
        $session = $this->getMock('Symfony\\Component\\HttpFoundation\\Session\\SessionInterface');
        $session->expects($this->never())->method('getBag');
        $tokenStorage = $this->getMock('Symfony\\Component\\Security\\Core\\Authentication\\Token\\Storage\\TokenStorageInterface');
        $tokenStorage->expects($this->once())->method('getToken')->willReturn($noUserReturn);
        $connection = $this->getMock('Doctrine\\DBAL\\Connection', [], [], '', false);
        $connection->expects($this->never())->method('prepare');
        $connection->expects($this->never())->method('execute');
        $listener = $this->getListener($session, $connection, $tokenStorage);
        $listener->setContainer($this->mockContainerWithContaoScopes(ContaoCoreBundle::SCOPE_BACKEND));
        $listener->onKernelResponse($responseEvent);
    }