8000 [Security] make the getter usable if no user identifier is set by xabbuh · Pull Request #41740 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Security] make the getter usable if no user identifier is set #41740

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function getMessageKey()
/**
* Get the user identifier (e.g. username or e-mailaddress).
*/
public function getUserIdentifier(): string
public function getUserIdentifier(): ?string
{
return $this->identifier;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
namespace Symfony\Component\Security\Core\Tests\Exception;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Security\Core\Exception\UserNotFoundException;
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
use Symfony\Component\Security\Core\Exception\UserNotFoundException;

class UserNotFoundExceptionTest extends TestCase
{
Expand All @@ -25,6 +25,23 @@ public function testGetMessageData()
$this->assertEquals(['{{ username }}' => 'username', '{{ user_identifier }}' => 'username'], $exception->getMessageData());
}

public function testUserIdentifierIsNotSetByDefault()
{
$exception = new UserNotFoundException();

$this->assertNull($exception->getUserIdentifier());
}

/**
* @group legacy
*/
public function testUsernameIsNotSetByDefault()
{
$exception = new UserNotFoundException();

$this->assertNull($exception->getUsername());
}

/**
* @group legacy
*/
Expand Down
0