@@ -267,4 +267,44 @@ public function test_config_login_fallback()
267267
268268 $ this ->assertFalse ($ outcome );
269269 }
270+
271+ public function test_config_login_fallback_no_connection ()
272+ {
273+ $ this ->app ['config ' ]->set ('adldap_auth.login_fallback ' , true );
274+
275+ $ mockedProvider = $ this ->mock (Provider::class);
276+ $ mockedSearch = $ this ->mock (Factory::class);
277+ $ mockedConnection = $ this ->mock (ConnectionInterface::class);
278+
279+ $ mockedConnection ->shouldReceive ('isBound ' )->once ()->andReturn (false );
280+
281+ $ mockedSearch ->shouldReceive ('select ' )->once ()->andReturn ($ mockedSearch );
282+ $ mockedSearch ->shouldReceive ('getConnection ' )->once ()->andReturn ($ mockedConnection );
283+
284+ $ manager = new Manager ();
285+
286+ $ manager ->add ('default ' , $ mockedProvider );
287+ $ mockedProvider ->shouldReceive ('search ' )->once ()->andReturn ($ mockedSearch );
288+
289+ Adldap::shouldReceive ('getManager ' )->andReturn ($ manager );
290+
291+ EloquentUser::create ([
292+ 'email ' => 'jdoe@email.com ' ,
293+ 'name ' => 'John Doe ' ,
294+ 'password ' => bcrypt ('Password123 ' ),
295+ ]);
296+
297+ $ credentials = [
298+ 'email ' => 'jdoe@email.com ' ,
299+ 'password ' => 'Password123 ' ,
300+ ];
301+
302+ $ outcome = Auth::attempt ($ credentials );
303+
304+ $ user = \Auth::user ();
305+
306+ $ this ->assertTrue ($ outcome );
307+ $ this ->assertInstanceOf ('Adldap\Laravel\Tests\Models\User ' , $ user );
308+ $ this ->assertEquals ('jdoe@email.com ' , $ user ->email );
309+ }
270310}
0 commit comments