Completed
Push — 2.x ( 14e460...6fcd32 )
by Grégoire
01:25
created

SwitchLocaleActionTest::testSwitchLocaleAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Sonata Project package.
5
 *
6
 * (c) Thomas Rabaix <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Sonata\TranslationBundle\Tests\Action;
13
14
use PHPUnit\Framework\TestCase;
15
use Sonata\TranslationBundle\Action\SwitchLocaleAction;
16
use Symfony\Component\HttpFoundation\Request;
17
use Symfony\Component\HttpFoundation\Session\Session;
18
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
19
20
/**
21
 * @author Jonathan Vautrin <[email protected]>
22
 */
23
class SwitchLocaleActionTest extends TestCase
24
{
25
    public function testSwitchLocaleAction()
26
    {
27
        $session = new Session(new MockArraySessionStorage());
28
        $session->set('_locale', 'en');
29
        $request = new Request();
30
        $request->setSession($session);
31
        $action = new SwitchLocaleAction();
32
        $action($request, 'fr');
33
        $this->assertSame('fr', $session->get('_locale'));
34
    }
35
}
36