Skip to content

Commit 6540930

Browse files
minor #48988 [Tests] New iteration of removing $this occurrences in future static data providers (alexandre-daubois)
This PR was merged into the 5.4 branch. Discussion ---------- [Tests] New iteration of removing `$this` occurrences in future static data providers | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes-ish | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | Easing symfony/symfony#48668 (comment) | License | MIT | Doc PR | _NA_ Follow-up of #48980 Commits ------- 1386ac2e81 [Tests] New iteration of removing `$this` occurrences in future static data providers
2 parents 0236efe + 7ef036c commit 6540930

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

Tests/Authentication/DefaultAuthenticationSuccessHandlerTest.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)