@@ -38,14 +38,26 @@ public function testRequestRedirections(Request $request, $options, $redirectedU
38
38
$ this ->assertSame ('http://localhost ' .$ redirectedUrl , $ handler ->onAuthenticationSuccess ($ request , $ token )->getTargetUrl ());
39
39
}
40
40
41
- public function getRequestRedirections ()
41
+ public function testRequestRedirectionsWithTargetPathInSessions ()
42
42
{
43
43
$ session = $ this ->createMock (SessionInterface::class);
44
44
$ session ->expects ($ this ->once ())->method ('get ' )->with ('_security.admin.target_path ' )->willReturn ('/admin/dashboard ' );
45
45
$ session ->expects ($ this ->once ())->method ('remove ' )->with ('_security.admin.target_path ' );
46
46
$ requestWithSession = Request::create ('/ ' );
47
47
$ requestWithSession ->setSession ($ session );
48
48
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
+ {
49
61
return [
50
62
'default ' => [
51
63
Request::create ('/ ' ),
@@ -72,11 +84,6 @@ public function getRequestRedirections()
72
84
['target_path_parameter ' => '_target_path[value] ' ],
73
85
'/dashboard ' ,
74
86
],
75
- 'target path in session ' => [
76
- $ requestWithSession ,
77
- [],
78
- '/admin/dashboard ' ,
79
- ],
80
87
'target path as referer ' => [
81
88
Request::create ('/ ' , 'GET ' , [], [], [], ['HTTP_REFERER ' => 'http://localhost/dashboard ' ]),
82
89
['use_referer ' => true ],
0 commit comments