@@ -119,7 +119,7 @@ public function testLoadUserByUsernameFailsIfMoreThanOneLdapPasswordsInEntry()
119
119
;
120
120
$ ldap = $ this ->getMockBuilder (LdapInterface::class)->getMock ();
121
121
$ result
122
- ->expects ($ this ->once ( ))
122
+ ->expects ($ this ->exactly ( 2 ))
123
123
->method ('offsetGet ' )
124
124
->with (0 )
125
125
->will ($ this ->returnValue (new Entry ('foo ' , array (
@@ -165,7 +165,7 @@ public function testLoadUserByUsernameFailsIfEntryHasNoPasswordAttribute()
165
165
;
166
166
$ ldap = $ this ->getMockBuilder (LdapInterface::class)->getMock ();
167
167
$ result
168
- ->expects ($ this ->once ( ))
168
+ ->expects ($ this ->exactly ( 2 ))
169
169
->method ('offsetGet ' )
170
170
->with (0 )
171
171
->will ($ this ->returnValue (new Entry ('foo ' , array (
@@ -207,7 +207,7 @@ public function testLoadUserByUsernameIsSuccessfulWithoutPasswordAttribute()
207
207
;
208
208
$ ldap = $ this ->getMockBuilder (LdapInterface::class)->getMock ();
209
209
$ result
210
- ->expects ($ this ->once ( ))
210
+ ->expects ($ this ->exactly ( 2 ))
211
211
->method ('offsetGet ' )
212
212
->with (0 )
213
213
->will ($ this ->returnValue (new Entry ('foo ' , array (
@@ -238,7 +238,7 @@ public function testLoadUserByUsernameIsSuccessfulWithoutPasswordAttribute()
238
238
);
239
239
}
240
240
241
- public function testLoadUserByUsernameIsSuccessfulWithPasswordAttribute ()
241
+ public function testLoadUserByUsernameIsSuccessfulWithoutPasswordAttributeAndWrongCase ()
242
242
{
243
243
$ result = $ this ->getMockBuilder (CollectionInterface::class)->getMock ();
244
244
$ query = $ this ->getMockBuilder (QueryInterface::class)->getMock ();
@@ -249,7 +249,46 @@ public function testLoadUserByUsernameIsSuccessfulWithPasswordAttribute()
249
249
;
250
250
$ ldap = $ this ->getMockBuilder (LdapInterface::class)->getMock ();
251
251
$ result
252
+ ->expects ($ this ->exactly (2 ))
253
+ ->method ('offsetGet ' )
254
+ ->with (0 )
255
+ ->will ($ this ->returnValue (new Entry ('foo ' , array (
256
+ 'sAMAccountName ' => array ('foo ' ),
257
+ )
258
+ )))
259
+ ;
260
+ $ result
261
+ ->expects ($ this ->once ())
262
+ ->method ('count ' )
263
+ ->will ($ this ->returnValue (1 ))
264
+ ;
265
+ $ ldap
266
+ ->expects ($ this ->once ())
267
+ ->method ('escape ' )
268
+ ->will ($ this ->returnValue ('Foo ' ))
269
+ ;
270
+ $ ldap
271
+ ->expects ($ this ->once ())
272
+ ->method ('query ' )
273
+ ->will ($ this ->returnValue ($ query ))
274
+ ;
275
+
276
+ $ provider = new LdapUserProvider ($ ldap , 'ou=MyBusiness,dc=symfony,dc=com ' );
277
+ $ this ->assertSame ('foo ' , $ provider ->loadUserByUsername ('Foo ' )->getUsername ());
278
+ }
279
+
280
+ public function testLoadUserByUsernameIsSuccessfulWithPasswordAttribute ()
281
+ {
282
+ $ result = $ this ->getMock (CollectionInterface::class);
283
+ $ query = $ this ->getMock (QueryInterface::class);
284
+ $ query
252
285
->expects ($ this ->once ())
286
+ ->method ('execute ' )
287
+ ->will ($ this ->returnValue ($ result ))
288
+ ;
289
+ $ ldap = $ this ->getMock (LdapInterface::class);
290
+ $ result
291
+ ->expects ($ this ->exactly (2 ))
253
292
->method ('offsetGet ' )
254
293
->with (0 )
255
294
->will ($ this ->returnValue (new Entry ('foo ' , array (
0 commit comments