@@ -119,7 +119,7 @@ public function testLoadUserByUsernameFailsIfMoreThanOneLdapPasswordsInEntry()
119119 ;
120120 $ ldap = $ this ->getMockBuilder (LdapInterface::class)->getMock ();
121121 $ result
122- ->expects ($ this ->once ( ))
122+ ->expects ($ this ->exactly ( 2 ))
123123 ->method ('offsetGet ' )
124124 ->with (0 )
125125 ->will ($ this ->returnValue (new Entry ('foo ' , array (
@@ -165,7 +165,7 @@ public function testLoadUserByUsernameFailsIfEntryHasNoPasswordAttribute()
165165 ;
166166 $ ldap = $ this ->getMockBuilder (LdapInterface::class)->getMock ();
167167 $ result
168- ->expects ($ this ->once ( ))
168+ ->expects ($ this ->exactly ( 2 ))
169169 ->method ('offsetGet ' )
170170 ->with (0 )
171171 ->will ($ this ->returnValue (new Entry ('foo ' , array (
@@ -207,7 +207,7 @@ public function testLoadUserByUsernameIsSuccessfulWithoutPasswordAttribute()
207207 ;
208208 $ ldap = $ this ->getMockBuilder (LdapInterface::class)->getMock ();
209209 $ result
210- ->expects ($ this ->once ( ))
210+ ->expects ($ this ->exactly ( 2 ))
211211 ->method ('offsetGet ' )
212212 ->with (0 )
213213 ->will ($ this ->returnValue (new Entry ('foo ' , array (
@@ -238,7 +238,7 @@ public function testLoadUserByUsernameIsSuccessfulWithoutPasswordAttribute()
238238 );
239239 }
240240
241- public function testLoadUserByUsernameIsSuccessfulWithPasswordAttribute ()
241+ public function testLoadUserByUsernameIsSuccessfulWithoutPasswordAttributeAndWrongCase ()
242242 {
243243 $ result = $ this ->getMockBuilder (CollectionInterface::class)->getMock ();
244244 $ query = $ this ->getMockBuilder (QueryInterface::class)->getMock ();
@@ -249,7 +249,46 @@ public function testLoadUserByUsernameIsSuccessfulWithPasswordAttribute()
249249 ;
250250 $ ldap = $ this ->getMockBuilder (LdapInterface::class)->getMock ();
251251 $ 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
252285 ->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 ))
253292 ->method ('offsetGet ' )
254293 ->with (0 )
255294 ->will ($ this ->returnValue (new Entry ('foo ' , array (
0 commit comments