1414use PHPUnit \Framework \TestCase ;
1515use Symfony \Component \Security \Core \Exception \UnsupportedUserException ;
1616use Symfony \Component \Security \Core \Exception \UserNotFoundException ;
17+ use Symfony \Component \Security \Core \User \AttributesBasedUserProviderInterface ;
1718use Symfony \Component \Security \Core \User \ChainUserProvider ;
1819use Symfony \Component \Security \Core \User \InMemoryUser ;
1920use Symfony \Component \Security \Core \User \InMemoryUserProvider ;
2021use Symfony \Component \Security \Core \User \PasswordAuthenticatedUserInterface ;
2122use Symfony \Component \Security \Core \User \PasswordUpgraderInterface ;
2223use Symfony \Component \Security \Core \User \UserInterface ;
24+ use Symfony \Component \Security \Core \User \UserProviderInterface ;
2325
2426class ChainUserProviderTest extends TestCase
2527{
@@ -45,6 +47,28 @@ public function testLoadUserByIdentifier()
4547 $ this ->assertSame ($ account , $ provider ->loadUserByIdentifier ('foo ' ));
4648 }
4749
50+ public function testLoadUserByIdentifierWithAttributes ()
51+ {
52+ $ provider1 = $ this ->createMock (UserProviderInterface::class);
53+ $ provider1
54+ ->expects ($ this ->once ())
55+ ->method ('loadUserByIdentifier ' )
56+ ->with ($ this ->equalTo ('foo ' ))
57+ ->willThrowException (new UserNotFoundException ('not found ' ))
58+ ;
59+
60+ $ provider2 = $ this ->createMock (AttributesBasedUserProviderInterface::class);
61+ $ provider2
62+ ->expects ($ this ->once ())
63+ ->method ('loadUserByIdentifier ' )
64+ ->with ($ this ->equalTo ('foo ' ), $ this ->equalTo (['attr ' => 5 ]))
65+ ->willReturn ($ account = $ this ->createMock (UserInterface::class))
66+ ;
67+
68+ $ provider = new ChainUserProvider ([$ provider1 , $ provider2 ]);
69+ $ this ->assertSame ($ account , $ provider ->loadUserByIdentifier ('foo ' , ['attr ' => 5 ]));
70+ }
71+
4872 public function testLoadUserByIdentifierThrowsUserNotFoundException ()
4973 {
5074 $ provider1 = $ this ->createMock (InMemoryUserProvider::class);
0 commit comments