8000 [FrameworkBundle][Test]: add token attributes in `KernelBrowser::logi… · symfony/symfony@1d38977 · GitHub
[go: up one dir, main page]

Skip to content
Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1d38977

Browse files
PEHAUT-PIETRI Valmontchalasr
PEHAUT-PIETRI Valmont
authored andcommitted
[FrameworkBundle][Test]: add token attributes in KernelBrowser::loginUser()
1 parent 7c833ee commit 1d38977

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ CHANGELOG
2424
* Deprecate not setting the `framework.validation.email_validation_mode` config option; it will default to `html5` in 7.0
2525
* Deprecate `framework.validation.enable_annotations`, use `framework.validation.enable_attributes` instead
2626
* Deprecate `framework.serializer.enable_annotations`, use `framework.serializer.enable_attributes` instead
27+
* Add `array $tokenAttributes = []` optional parameter to `KernelBrowser::loginUser()`
2728

2829
6.3
2930
---

src/Symfony/Bundle/FrameworkBundle/KernelBrowser.php

Lines changed: 6 additions & 2 deletions
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 = 2 < \func_num_args() ? 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)
0