8000 make the getter usable if no user identifier is set · symfony/symfony@148750e · GitHub
[go: up one dir, main page]

Skip to content

Commit 148750e

Browse files
committed
make the getter usable if no user identifier is set
1 parent 473f79c commit 148750e

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/Symfony/Component/Security/Core/Exception/UserNotFoundException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function getMessageKey()
3232
/**
3333
* Get the user identifier (e.g. username or e-mailaddress).
3434
*/
35-
public function getUserIdentifier(): string
35+
public function getUserIdentifier(): ?string
3636
{
3737
return $this->identifier;
3838
}

src/Symfony/Component/Security/Core/Tests/Exception/UserNotFoundExceptionTest.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
namespace Symfony\Component\Security\Core\Tests\Exception;
1313

1414
use PHPUnit\Framework\TestCase;
15-
use Symfony\Component\Security\Core\Exception\UserNotFoundException;
1615
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
16+
use Symfony\Component\Security\Core\Exception\UserNotFoundException;
1717

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

28+
public function testUserIdentifierIsNotSetByDefault()
29+
{
30+
$exception = new UserNotFoundException();
31+
32+
$this->assertNull($exception->getUserIdentifier());
33+
}
34+
35+
/**
36+
* @group legacy
37+
*/
38+
public function testUsernameIsNotSetByDefault()
39+
{
40+
$exception = new UserNotFoundException();
41+
42+
$this->assertNull($exception->getUsername());
43+
}
44+
2845
/**
2946
* @group legacy
3047
*/

0 commit comments

Comments
 (0)
0