From 85097f6eb84027365cdb9c565faab8e4111fbd0e Mon Sep 17 00:00:00 2001 From: Caleb Porzio Date: Thu, 13 Apr 2017 13:58:14 -0400 Subject: [PATCH] Make SessionGuard Macroable with test (#18796) --- src/Illuminate/Auth/SessionGuard.php | 3 ++- tests/Auth/AuthGuardTest.php | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/Auth/SessionGuard.php b/src/Illuminate/Auth/SessionGuard.php index 1ab4723074d5..a1ed4b78104b 100644 --- a/src/Illuminate/Auth/SessionGuard.php +++ b/src/Illuminate/Auth/SessionGuard.php @@ -5,6 +5,7 @@ use RuntimeException; use Illuminate\Support\Str; use Illuminate\Http\Response; +use Illuminate\Support\Traits\Macroable; use Illuminate\Contracts\Session\Session; use Illuminate\Contracts\Auth\UserProvider; use Illuminate\Contracts\Events\Dispatcher; @@ -16,7 +17,7 @@ class SessionGuard implements StatefulGuard, SupportsBasicAuth { - use GuardHelpers; + use GuardHelpers, Macroable; /** * The name of the Guard. Typically "session". diff --git a/tests/Auth/AuthGuardTest.php b/tests/Auth/AuthGuardTest.php index a092eee1b9a9..f10d7d3228a6 100755 --- a/tests/Auth/AuthGuardTest.php +++ b/tests/Auth/AuthGuardTest.php @@ -111,6 +111,19 @@ public function testLoginStoresIdentifierInSession() $mock->login($user); } + public function testSessionGuardIsMacroable() + { + $guard = $this->getGuard(); + + $guard->macro('foo', function () { + return 'bar'; + }); + + $this->assertEquals( + 'bar', $guard->foo() + ); + } + public function testLoginFiresLoginAndAuthenticatedEvents() { list($session, $provider, $request, $cookie) = $this->getMocks();