Skip to content

Commit 1a59631

Browse files
committed
feature #40443 [Security] Rename User to InMemoryUser (chalasr)
This PR was merged into the 5.3-dev branch. Discussion ---------- [Security] Rename User to InMemoryUser | Q | A | ------------- | --- | Branch? | 5.x | Bug fix? | no | New feature? | yes | Deprecations? | yes | Tickets | Closes #26348 | License | MIT | Doc PR | - This PR aims to clarify that the `User` class should only be used by the `InMemoryUserProvider`, as documented: https://github.com/symfony/symfony/blob/c06a76c38410ac027abce10a68bc219add7bf07d/src/Symfony/Component/Security/Core/User/User.php#L15-L17 It also renames `UserChecker` to `InMemoryUserChecker` because it only works with the in-memory user class: https://github.com/symfony/symfony/blob/c06a76c38410ac027abce10a68bc219add7bf07d/src/Symfony/Component/Security/Core/User/UserChecker.php#L31-L32 Commits ------- 55b51d3f90 [Security] Rename User to InMemoryUser
2 parents 1073e98 + c1eba51 commit 1a59631

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

Tests/Controller/AbstractControllerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@
3838
use Symfony\Component\HttpFoundation\StreamedResponse;
3939
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
4040
use Symfony\Component\HttpKernel\HttpKernelInterface;
41+
use Symfony\Component\Routing\RouterInterface;
4142
use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken;
4243
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
4344
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
4445
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
4546
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
46-
use Symfony\Component\Security\Core\User\User;
47+
use Symfony\Component\Security\Core\User\InMemoryUser;
4748
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
4849
use Symfony\Component\Serializer\SerializerInterface;
49-
use Symfony\Component\Routing\RouterInterface;
5050
use Symfony\Component\WebLink\Link;
5151
use Twig\Environment;
5252

@@ -137,7 +137,7 @@ public function testForward()
137137

138138
public function testGetUser()
139139
{
140-
$user = new User('user', 'pass');
140+
$user = new InMemoryUser('user', 'pass');
141141
$token = new UsernamePasswordToken($user, 'pass', 'default', ['ROLE_USER']);
142142

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

Tests/Functional/SecurityTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional;
1313

14-
use Symfony\Component\Security\Core\User\User;
14+
use Symfony\Component\Security\Core\User\InMemoryUser;
1515

1616
class SecurityTest extends AbstractWebTestCase
1717
{
@@ -20,7 +20,7 @@ class SecurityTest extends AbstractWebTestCase
2020
*/
2121
public function testLoginUser(string $username, array $roles, ?string $firewallContext)
2222
{
23-
$user = new User($username, 'the-password', $roles);
23+
$user = new InMemoryUser($username, 'the-password', $roles);
2424
$client = $this->createClient(['test_case' => 'Security', 'root_config' => 'config.yml']);
2525

2626
if (null === $firewallContext) {
@@ -45,7 +45,7 @@ public function getUsers()
4545

4646
public function testLoginUserMultipleRequests()
4747
{
48-
$user = new User('the-username', 'the-password', ['ROLE_FOO']);
48+
$user = new InMemoryUser('the-username', 'the-password', ['ROLE_FOO']);
4949
$client = $this->createClient(['test_case' => 'Security', 'root_config' => 'config.yml']);
5050
$client->loginUser($user);
5151

@@ -58,7 +58,7 @@ public function testLoginUserMultipleRequests()
5858

5959
public function testLoginInBetweenRequests()
6060
{
61-
$user = new User('the-username', 'the-password', ['ROLE_FOO']);
61+
$user = new InMemoryUser('the-username', 'the-password', ['ROLE_FOO']);
6262
$client = $this->createClient(['test_case' => 'Security', 'root_config' => 'config.yml']);
6363

6464
$client->request('GET', '/main/user_profile');

0 commit comments

Comments
 (0)