@@ -333,6 +333,52 @@ public function testLoadUserByUsernameIsSuccessfulWithPasswordAttribute()
333
333
$ this ->assertInstanceOf (LdapUser::class, $ provider ->loadUserByIdentifier ('foo ' ));
334
334
}
335
335
336
+ public function testLoadUserByIdentifierIsSuccessfulWithMultipleExtraAttributes ()
337
+ {
338
+ $ result = $ this ->createMock (CollectionInterface::class);
339
+ $ query = $ this ->createMock (QueryInterface::class);
340
+ $ query
341
+ ->expects ($ this ->once ())
342
+ ->method ('execute ' )
343
+ ->willReturn ($ result )
344
+ ;
345
+ $ ldap = $ this ->createMock (LdapInterface::class);
346
+ $ memberOf = [
347
+ 'cn=foo,ou=MyBusiness,dc=symfony,dc=com ' ,
348
+ 'cn=bar,ou=MyBusiness,dc=symfony,dc=com ' ,
349
+ ];
350
+ $ result
351
+ ->expects ($ this ->once ())
352
+ ->method ('offsetGet ' )
353
+ ->with (0 )
354
+ ->willReturn (new Entry ('foo ' , [
355
+ 'sAMAccountName ' => ['foo ' ],
356
+ 'userpassword ' => ['bar ' ],
357
+ 'memberOf ' => $ memberOf ,
358
+ ]))
359
+ ;
360
+ $ result
361
+ ->expects ($ this ->once ())
362
+ ->method ('count ' )
363
+ ->willReturn (1 )
364
+ ;
365
+ $ ldap
366
+ ->expects ($ this ->once ())
367
+ ->method ('escape ' )
368
+ ->willReturn ('foo ' )
369
+ ;
370
+ $ ldap
371
+ ->expects ($ this ->once ())
372
+ ->method ('query ' )
373
+ ->willReturn ($ query )
374
+ ;
375
+
376
+ $ provider = new LdapUserProvider ($ ldap , 'ou=MyBusiness,dc=symfony,dc=com ' , null , null , [], 'sAMAccountName ' , '({uid_key}={user_identifier}) ' , 'userpassword ' , ['memberOf ' ]);
377
+ $ user = $ provider ->loadUserByIdentifier ('foo ' );
378
+ $ this ->assertInstanceOf (LdapUser::class, $ user );
379
+ $ this ->assertSame (['memberOf ' => $ memberOf ], $ user ->getExtraFields ());
380
+ }
381
+
336
382
public function testRefreshUserShouldReturnUserWithSameProperties ()
337
383
{
338
384
$ ldap = $ this ->createMock (LdapInterface::class);
0 commit comments