14
14
use PHPUnit \Framework \TestCase ;
15
15
use Symfony \Component \Security \Core \Exception \UnsupportedUserException ;
16
16
use Symfony \Component \Security \Core \Exception \UserNotFoundException ;
17
+ use Symfony \Component \Security \Core \User \AttributesBasedUserProviderInterface ;
17
18
use Symfony \Component \Security \Core \User \ChainUserProvider ;
18
19
use Symfony \Component \Security \Core \User \InMemoryUser ;
19
20
use Symfony \Component \Security \Core \User \InMemoryUserProvider ;
20
21
use Symfony \Component \Security \Core \User \PasswordAuthenticatedUserInterface ;
21
22
use Symfony \Component \Security \Core \User \PasswordUpgraderInterface ;
22
23
use Symfony \Component \Security \Core \User \UserInterface ;
24
+ use Symfony \Component \Security \Core \User \UserProviderInterface ;
23
25
24
26
class ChainUserProviderTest extends TestCase
25
27
{
@@ -45,6 +47,28 @@ public function testLoadUserByIdentifier()
45
47
$ this ->assertSame ($ account , $ provider ->loadUserByIdentifier ('foo ' ));
46
48
}
47
49
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
+
48
72
public function testLoadUserByIdentifierThrowsUserNotFoundException ()
49
73
{
50
74
$ this ->expectException (UserNotFoundException::class);
0 commit comments