8000 Fix compatibility with symfony/security-core 6.x · symfony/symfony@e044b17 · GitHub
[go: up one dir, main page]

Skip to content

Commit e044b17

Browse files
committed
Fix compatibility with symfony/security-core 6.x
1 parent d7019da commit e044b17

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/Symfony/Bundle/FrameworkBundle/KernelBrowser.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,10 @@ public function loginUser(object $user, string $firewallContext = 'main'): self
123123
}
124124

125125
$token = new TestBrowserToken($user->getRoles(), $user, $firewallContext);
126-
$token->setAuthenticated(true);
126+
// @deprecated since Symfony 5.4
127+
if (method_exists($token, 'setAuthenticated')) {
128+
$token->setAuthenticated(true);
129+
}
127130

128131
$container = $this->getContainer();
129132
$container->get('security.untracked_token_storage')->setToken($token);

src/Symfony/Bundle/FrameworkBundle/Tests/Controller/AbstractControllerTest.php

Lines changed: 11 additions & 1 deletion
659C
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,12 @@ public function testForward()
138138
public function testGetUser()
139139
{
140140
$user = new InMemoryUser('user', 'pass');
141-
$token = new UsernamePasswordToken($user, 'pass', 'default', ['ROLE_USER']);
141+
if (method_exists(UsernamePasswordToken::class, 'setAuthenticated')) {
142+
// @deprecated since Symfony 5.4
143+
$token = new UsernamePasswordToken($user, 'pass', 'default', ['ROLE_USER']);
144+
} else {
145+
$token = new UsernamePasswordToken($user, 'default', ['ROLE_USER']);
146+
}
142147

143148
$controller = $this->createController();
144149
$controller->setContainer($this->getContainerWithTokenStorage($token));
@@ -148,6 +153,11 @@ public function testGetUser()
148153

149154
public function testGetUserAnonymousUserConvertedToNull()
150155
{
156+
// @deprecated since Symfony 5.4
157+
if (!class_exists(AnonymousToken::class)) {
158+
$this->markTestSkipped('This test requires "symfony/security-core" <6.0.');
159+
}
160+
151161
$token = new AnonymousToken('default', 'anon.');
152162

153163
$controller = $this->createController();

0 commit comments

Comments
 (0)
0