12
12
namespace Symfony \Component \HttpKernel \Tests \EventListener ;
13
13
14
14
use PHPUnit \Framework \TestCase ;
15
+ use Symfony \Component \EventDispatcher \EventSubscriberInterface ;
15
16
use Symfony \Component \HttpFoundation \Request ;
16
17
use Symfony \Component \HttpKernel \Event \GetResponseEvent ;
17
18
use Symfony \Component \HttpKernel \EventListener \LocaleListener ;
@@ -29,29 +30,26 @@ protected function setUp()
29
30
30
31
public function testIsAnEventSubscriber ()
31
32
{
32
- $ this ->assertInstanceOf (
33
- 'Symfony\Component\EventDispatcher\EventSubscriberInterface ' ,
34
- new LocaleListener ($ this ->requestStack )
35
- );
33
+ $ this ->assertInstanceOf (EventSubscriberInterface::class, new LocaleListener ($ this ->requestStack ));
36
34
}
37
35
38
36
public function testRegisteredEvent ()
39
37
{
40
38
$ this ->assertEquals (
41
39
array (
42
- KernelEvents::REQUEST => array (array ('onKernelRequestEarly ' , 100 ), array ('onKernelRequest ' , 16 )),
40
+ KernelEvents::REQUEST => array (array ('setDefaultLocale ' , 100 ), array ('onKernelRequest ' , 16 )),
43
41
KernelEvents::FINISH_REQUEST => array (array ('onKernelFinishRequest ' , 0 )),
44
42
),
45
43
LocaleListener::getSubscribedEvents ()
46
44
);
47
45
}
48
46
49
- public function testDefaultLocaleWithoutSession ()
47
+ public function testDefaultLocale ()
50
48
{
51
49
$ listener = new LocaleListener ($ this ->requestStack , 'fr ' );
52
50
$ event = $ this ->getEvent ($ request = Request::create ('/ ' ));
53
51
54
- $ listener ->onKernelRequestEarly ($ event );
52
+ $ listener ->setDefaultLocale ($ event );
55
53
$ this ->assertEquals ('fr ' , $ request ->getLocale ());
56
54
}
57
55
0 commit comments