Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 955ff13

Browse files
author
PEHAUT-PIETRI Valmont
committed
[FrameworkBundle][Test]: add token attributes in KernelBrowser::loginUser()
1 parent 8bacb78 commit 955ff13

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/Symfony/Bundle/FrameworkBundle/KernelBrowser.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,15 @@ public function enableReboot()
107107
}
108108

109109
/**
110-
* @param UserInterface $user
110+
* @param UserInterface $user
111+
* @param array<string, mixed> $tokenAttributes
111112
*
112113
* @return $this
113114
*/
114-
public function loginUser(object $user, string $firewallContext = 'main'): static
115+
public function loginUser(object $user, string $firewallContext = 'main'/* , array $tokenAttributes = [] */): static
115116
{
117+
$tokenAttributes = \func_num_args() > 2 ? func_get_arg(2) : [];
118+
116119
if (!interface_exists(UserInterface::class)) {
117120
throw new \LogicException(sprintf('"%s" requires symfony/security-core to be installed. Try running "composer require symfony/security-core".', __METHOD__));
118121
}
@@ -122,6 +125,7 @@ public function loginUser(object $user, string $firewallContext = 'main'): stati
122125
}
123126

124127
$token = new TestBrowserToken($user->getRoles(), $user, $firewallContext);
128+
$token->setAttributes($tokenAttributes);
125129
// required for compatibility with Symfony 5.4
126130
if (method_exists($token, 'isAuthenticated')) {
127131
$token->setAuthenticated(true, false);

0 commit comments

Comments
 (0)