@@ -359,6 +359,27 @@ public function testUserUsesRememberCookieIfItExists()
359359 $ this ->assertTrue ($ guard ->viaRemember ());
360360 }
361361
362+ public function testLoginOnceSetsUser ()
363+ {
364+ list ($ session , $ provider , $ request , $ cookie ) = $ this ->getMocks ();
365+ $ guard = m::mock ('Illuminate\Auth\SessionGuard ' , ['default ' , $ provider , $ session ])->makePartial ();
366+ $ user = m::mock ('Illuminate\Contracts\Auth\Authenticatable ' );
367+ $ guard ->getProvider ()->shouldReceive ('retrieveByCredentials ' )->once ()->with (['foo ' ])->andReturn ($ user );
368+ $ guard ->getProvider ()->shouldReceive ('validateCredentials ' )->once ()->with ($ user , ['foo ' ])->andReturn (true );
369+ $ guard ->shouldReceive ('setUser ' )->once ()->with ($ user );
370+ $ this ->assertTrue ($ guard ->once (['foo ' ]));
371+ }
372+
373+ public function testLoginOnceFailure ()
374+ {
375+ list ($ session , $ provider , $ request , $ cookie ) = $ this ->getMocks ();
376+ $ guard = m::mock ('Illuminate\Auth\SessionGuard ' , ['default ' , $ provider , $ session ])->makePartial ();
377+ $ user = m::mock ('Illuminate\Contracts\Auth\Authenticatable ' );
378+ $ guard ->getProvider ()->shouldReceive ('retrieveByCredentials ' )->once ()->with (['foo ' ])->andReturn ($ user );
379+ $ guard ->getProvider ()->shouldReceive ('validateCredentials ' )->once ()->with ($ user , ['foo ' ])->andReturn (false );
380+ $ this ->assertFalse ($ guard ->once (['foo ' ]));
381+ }
382+
362383 protected function getGuard ()
363384 {
364385 list ($ session , $ provider , $ request , $ cookie ) = $ this ->getMocks ();
0 commit comments