Skip to content

Commit 85097f6

Browse files
calebporziotaylorotwell
authored andcommitted
Make SessionGuard Macroable with test (#18796)
1 parent a73aede commit 85097f6

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/Illuminate/Auth/SessionGuard.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use RuntimeException;
66
use Illuminate\Support\Str;
77
use Illuminate\Http\Response;
8+
use Illuminate\Support\Traits\Macroable;
89
use Illuminate\Contracts\Session\Session;
910
use Illuminate\Contracts\Auth\UserProvider;
1011
use Illuminate\Contracts\Events\Dispatcher;
@@ -16,7 +17,7 @@
1617

1718
class SessionGuard implements StatefulGuard, SupportsBasicAuth
1819
{
19-
use GuardHelpers;
20+
use GuardHelpers, Macroable;
2021

2122
/**
2223
* The name of the Guard. Typically "session".

tests/Auth/AuthGuardTest.php

+13
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,19 @@ public function testLoginStoresIdentifierInSession()
111111
$mock->login($user);
112112
}
113113

114+
public function testSessionGuardIsMacroable()
115+
{
116+
$guard = $this->getGuard();
117+
118+
$guard->macro('foo', function () {
119+
return 'bar';
120+
});
121+
122+
$this->assertEquals(
123+
'bar', $guard->foo()
124+
);
125+
}
126+
114127
public function testLoginFiresLoginAndAuthenticatedEvents()
115128
{
116129
list($session, $provider, $request, $cookie) = $this->getMocks();

0 commit comments

Comments
 (0)