Contao\CoreBundle\Test\EventListener\LocaleListenerTest::testWithSessionValue PHP Method

testWithSessionValue() public method

Tests the onKernelRequest() method with the session locale.
public testWithSessionValue ( string $locale, string $expected )
$locale string
$expected string
    public function testWithSessionValue($locale, $expected)
    {
        // The session values are already formatted, so we're passing in $expected here
        $session = $this->mockSession();
        $session->set('_locale', $expected);
        $request = Request::create('/');
        $request->setSession($session);
        $event = new GetResponseEvent($this->mockKernel(), $request, HttpKernelInterface::MASTER_REQUEST);
        $listener = new LocaleListener(['en']);
        $listener->setContainer($this->mockContainerWithContaoScopes(ContaoCoreBundle::SCOPE_FRONTEND));
        $listener->onKernelRequest($event);
        $this->assertEquals($expected, $request->attributes->get('_locale'));
        $this->assertEquals($expected, $session->get('_locale'));
    }