From 58eca5b19ba25497f964a74e0c98ac9ad875a1c2 Mon Sep 17 00:00:00 2001 From: mpyw Date: Fri, 8 Jun 2018 23:57:59 +0900 Subject: [PATCH] Add test of Add GuardHelpers::alreadyAuthenticated() --- tests/Auth/AuthGuardTest.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/Auth/AuthGuardTest.php b/tests/Auth/AuthGuardTest.php index 85bf17b30b36..ed09ed320aaf 100755 --- a/tests/Auth/AuthGuardTest.php +++ b/tests/Auth/AuthGuardTest.php @@ -178,6 +178,22 @@ public function testAuthenticateThrowsWhenUserIsNull() $guard->authenticate(); } + public function testAlreadyAuthenticatedReturnsFalseWhenUserIsNotNull() + { + $user = m::mock('Illuminate\Contracts\Auth\Authenticatable'); + $guard = $this->getGuard()->setUser($user); + + $this->assertTrue($guard->alreadyAuthenticated()); + } + + public function testAlreadyAuthenticatedReturnsFalseWhenUserIsNull() + { + $guard = $this->getGuard(); + $guard->getSession()->shouldNotReceive('get'); + + $this->assertFalse($guard->alreadyAuthenticated()); + } + public function testIsAuthedReturnsTrueWhenUserIsNotNull() { $user = m::mock('Illuminate\Contracts\Auth\Authenticatable');