@@ -38,14 +38,26 @@ public function testRequestRedirections(Request $request, $options, $redirectedU
3838 $ this ->assertSame ('http://localhost ' .$ redirectedUrl , $ handler ->onAuthenticationSuccess ($ request , $ token )->getTargetUrl ());
3939 }
4040
41- public function getRequestRedirections ()
41+ public function testRequestRedirectionsWithTargetPathInSessions ()
4242 {
4343 $ session = $ this ->createMock (SessionInterface::class);
4444 $ session ->expects ($ this ->once ())->method ('get ' )->with ('_security.admin.target_path ' )->willReturn ('/admin/dashboard ' );
4545 $ session ->expects ($ this ->once ())->method ('remove ' )->with ('_security.admin.target_path ' );
4646 $ requestWithSession = Request::create ('/ ' );
4747 $ requestWithSession ->setSession ($ session );
4848
49+ $ urlGenerator = $ this ->createMock (UrlGeneratorInterface::class);
50+ $ urlGenerator ->expects ($ this ->any ())->method ('generate ' )->willReturn ('http://localhost/login ' );
51+ $ httpUtils = new HttpUtils ($ urlGenerator );
52+ $ token = $ this ->createMock (TokenInterface::class);
53+ $ handler = new DefaultAuthenticationSuccessHandler ($ httpUtils );
54+ $ handler ->setFirewallName ('admin ' );
55+
56+ $ this ->assertSame ('http://localhost/admin/dashboard ' , $ handler ->onAuthenticationSuccess ($ requestWithSession , $ token )->getTargetUrl ());
57+ }
58+
59+ public static function getRequestRedirections ()
60+ {
4961 return [
5062 'default ' => [
5163 Request::create ('/ ' ),
@@ -72,11 +84,6 @@ public function getRequestRedirections()
7284 ['target_path_parameter ' => '_target_path[value] ' ],
7385 '/dashboard ' ,
7486 ],
75- 'target path in session ' => [
76- $ requestWithSession ,
77- [],
78- '/admin/dashboard ' ,
79- ],
8087 'target path as referer ' => [
8188 Request::create ('/ ' , 'GET ' , [], [], [], ['HTTP_REFERER ' => 'http://localhost/dashboard ' ]),
8289 ['use_referer ' => true ],
0 commit comments