FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
framework/tests/Auth/AuthGuardTest.php at master · JavaDevl/framework · GitHub
JavaDevl
/
framework
Public
forked from
laravel/framework
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
framework
/
tests
/
Auth
/
AuthGuardTest.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
307 lines (272 loc) · 15.5 KB
Breadcrumbs
framework
/
tests
/
Auth
/
AuthGuardTest.php
Copy path
File metadata and controls
executable file
·
307 lines (272 loc) · 15.5 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
<?php
use
Mockery
as
m
;
use
Symfony
\
Component
\
HttpFoundation
\
Request
;
use
Illuminate
\
Auth
\
Events
\
Attempting
;
class
AuthGuardTest
extends
PHPUnit_Framework_TestCase
{
public
function
tearDown
()
{
m::
close
();
}
public
function
testBasicReturnsNullOnValidAttempt
()
{
list
(
$
session
,
$
provider
,
$
request
,
$
cookie
) =
$
this
->
getMocks
();
$
guard
= m::
mock
(
'
Illuminate\Auth\SessionGuard[check,attempt]
'
, [
'
default
'
,
$
provider
,
$
session
]);
$
guard
->
shouldReceive
(
'
check
'
)->
once
()->
andReturn
(
false
);
$
guard
->
shouldReceive
(
'
attempt
'
)->
once
()->
with
([
'
email
'
=>
'
foo@bar.com
'
,
'
password
'
=>
'
secret
'
])->
andReturn
(
true
);
$
request
=
Symfony
\
Component
\
HttpFoundation
\Request::
create
(
'
/
'
,
'
GET
'
, [], [], [], [
'
PHP_AUTH_USER
'
=>
'
foo@bar.com
'
,
'
PHP_AUTH_PW
'
=>
'
secret
'
]);
$
guard
->
setRequest
(
$
request
);
$
guard
->
basic
(
'
email
'
);
}
public
function
testBasicReturnsNullWhenAlreadyLoggedIn
()
{
list
(
$
session
,
$
provider
,
$
request
,
$
cookie
) =
$
this
->
getMocks
();
$
guard
= m::
mock
(
'
Illuminate\Auth\SessionGuard[check]
'
, [
'
default
'
,
$
provider
,
$
session
]);
$
guard
->
shouldReceive
(
'
check
'
)->
once
()->
andReturn
(
true
);
$
guard
->
shouldReceive
(
'
attempt
'
)->
never
();
$
request
=
Symfony
\
Component
\
HttpFoundation
\Request::
create
(
'
/
'
,
'
GET
'
, [], [], [], [
'
PHP_AUTH_USER
'
=>
'
foo@bar.com
'
,
'
PHP_AUTH_PW
'
=>
'
secret
'
]);
$
guard
->
setRequest
(
$
request
);
$
guard
->
basic
(
'
email
'
);
}
public
function
testBasicReturnsResponseOnFailure
()
{
list
(
$
session
,
$
provider
,
$
request
,
$
cookie
) =
$
this
->
getMocks
();
$
guard
= m::
mock
(
'
Illuminate\Auth\SessionGuard[check,attempt]
'
, [
'
default
'
,
$
provider
,
$
session
]);
$
guard
->
shouldReceive
(
'
check
'
)->
once
()->
andReturn
(
false
);
$
guard
->
shouldReceive
(
'
attempt
'
)->
once
()->
with
([
'
email
'
=>
'
foo@bar.com
'
,
'
password
'
=>
'
secret
'
])->
andReturn
(
false
);
$
request
=
Symfony
\
Component
\
HttpFoundation
\Request::
create
(
'
/
'
,
'
GET
'
, [], [], [], [
'
PHP_AUTH_USER
'
=>
'
foo@bar.com
'
,
'
PHP_AUTH_PW
'
=>
'
secret
'
]);
$
guard
->
setRequest
(
$
request
);
$
response
=
$
guard
->
basic
(
'
email
'
);
$
this
->
assertInstanceOf
(
'
Symfony\Component\HttpFoundation\Response
'
,
$
response
);
$
this
->
assertEquals
(
401
,
$
response
->
getStatusCode
());
}
public
function
testBasicWithExtraConditions
()
{
list
(
$
session
,
$
provider
,
$
request
,
$
cookie
) =
$
this
->
getMocks
();
$
guard
= m::
mock
(
'
Illuminate\Auth\SessionGuard[check,attempt]
'
, [
'
default
'
,
$
provider
,
$
session
]);
$
guard
->
shouldReceive
(
'
check
'
)->
once
()->
andReturn
(
false
);
$
guard
->
shouldReceive
(
'
attempt
'
)->
once
()->
with
([
'
email
'
=>
'
foo@bar.com
'
,
'
password
'
=>
'
secret
'
,
'
active
'
=>
1
])->
andReturn
(
true
);
$
request
=
Symfony
\
Component
\
HttpFoundation
\Request::
create
(
'
/
'
,
'
GET
'
, [], [], [], [
'
PHP_AUTH_USER
'
=>
'
foo@bar.com
'
,
'
PHP_AUTH_PW
'
=>
'
secret
'
]);
$
guard
->
setRequest
(
$
request
);
$
guard
->
basic
(
'
email
'
, [
'
active
'
=>
1
]);
}
public
function
testAttemptCallsRetrieveByCredentials
()
{
$
guard
=
$
this
->
getGuard
();
$
guard
->
setDispatcher
(
$
events
= m::
mock
(
'
Illuminate\Contracts\Events\Dispatcher
'
));
$
events
->
shouldReceive
(
'
fire
'
)->
once
()->
with
(m::
type
(Attempting::class));
$
guard
->
getProvider
()->
shouldReceive
(
'
retrieveByCredentials
'
)->
once
()->
with
([
'
foo
'
]);
$
guard
->
attempt
([
'
foo
'
]);
}
public
function
testAttemptReturnsUserInterface
()
{
list
(
$
session
,
$
provider
,
$
request
,
$
cookie
) =
$
this
->
getMocks
();
$
guard
=
$
this
->
getMock
(
'
Illuminate\Auth\SessionGuard
'
, [
'
login
'
], [
'
default
'
,
$
provider
,
$
session
,
$
request
]);
$
guard
->
setDispatcher
(
$
events
= m::
mock
(
'
Illuminate\Contracts\Events\Dispatcher
'
));
$
events
->
shouldReceive
(
'
fire
'
)->
once
()->
with
(m::
type
(Attempting::class));
$
user
=
$
this
->
getMock
(
'
Illuminate\Contracts\Auth\Authenticatable
'
);
$
guard
->
getProvider
()->
shouldReceive
(
'
retrieveByCredentials
'
)->
once
()->
andReturn
(
$
user
);
$
guard
->
getProvider
()->
shouldReceive
(
'
validateCredentials
'
)->
with
(
$
user
, [
'
foo
'
])->
andReturn
(
true
);
$
guard
->
expects
(
$
this
->
once
())->
method
(
'
login
'
)->
with
(
$
this
->
equalTo
(
$
user
));
$
this
->
assertTrue
(
$
guard
->
attempt
([
'
foo
'
]));
}
public
function
testAttemptReturnsFalseIfUserNotGiven
()
{
$
mock
=
$
this
->
getGuard
();
$
mock
->
setDispatcher
(
$
events
= m::
mock
(
'
Illuminate\Contracts\Events\Dispatcher
'
));
$
events
->
shouldReceive
(
'
fire
'
)->
once
()->
with
(m::
type
(Attempting::class));
$
mock
->
getProvider
()->
shouldReceive
(
'
retrieveByCredentials
'
)->
once
()->
andReturn
(
null
);
$
this
->
assertFalse
(
$
mock
->
attempt
([
'
foo
'
]));
}
public
function
testLoginStoresIdentifierInSession
()
{
list
(
$
session
,
$
provider
,
$
request
,
$
cookie
) =
$
this
->
getMocks
();
$
mock
=
$
this
->
getMock
(
'
Illuminate\Auth\SessionGuard
'
, [
'
getName
'
], [
'
default
'
,
$
provider
,
$
session
,
$
request
]);
$
user
= m::
mock
(
'
Illuminate\Contracts\Auth\Authenticatable
'
);
$
mock
->
expects
(
$
this
->
once
())->
method
(
'
getName
'
)->
will
(
$
this
->
returnValue
(
'
foo
'
));
$
user
->
shouldReceive
(
'
getAuthIdentifier
'
)->
once
()->
andReturn
(
'
bar
'
);
$
mock
->
getSession
()->
shouldReceive
(
'
set
'
)->
with
(
'
foo
'
,
'
bar
'
)->
once
();
$
session
->
shouldReceive
(
'
migrate
'
)->
once
();
$
mock
->
login
(
$
user
);
}
public
function
testLoginFiresLoginEvent
()
{
list
(
$
session
,
$
provider
,
$
request
,
$
cookie
) =
$
this
->
getMocks
();
$
mock
=
$
this
->
getMock
(
'
Illuminate\Auth\SessionGuard
'
, [
'
getName
'
], [
'
default
'
,
$
provider
,
$
session
,
$
request
]);
$
mock
->
setDispatcher
(
$
events
= m::
mock
(
'
Illuminate\Contracts\Events\Dispatcher
'
));
$
user
= m::
mock
(
'
Illuminate\Contracts\Auth\Authenticatable
'
);
$
events
->
shouldReceive
(
'
fire
'
)->
once
()->
with
(m::
type
(
'
Illuminate\Auth\Events\Login
'
));
$
mock
->
expects
(
$
this
->
once
())->
method
(
'
getName
'
)->
will
(
$
this
->
returnValue
(
'
foo
'
));
$
user
->
shouldReceive
(
'
getAuthIdentifier
'
)->
once
()->
andReturn
(
'
bar
'
);
$
mock
->
getSession
()->
shouldReceive
(
'
set
'
)->
with
(
'
foo
'
,
'
bar
'
)->
once
();
$
session
->
shouldReceive
(
'
migrate
'
)->
once
();
$
mock
->
login
(
$
user
);
}
public
function
testIsAuthedReturnsTrueWhenUserIsNotNull
()
{
$
user
= m::
mock
(
'
Illuminate\Contracts\Auth\Authenticatable
'
);
$
mock
=
$
this
->
getGuard
();
$
mock
->
setUser
(
$
user
);
$
this
->
assertTrue
(
$
mock
->
check
());
$
this
->
assertFalse
(
$
mock
->
guest
());
}
public
function
testIsAuthedReturnsFalseWhenUserIsNull
()
{
list
(
$
session
,
$
provider
,
$
request
,
$
cookie
) =
$
this
->
getMocks
();
$
mock
=
$
this
->
getMock
(
'
Illuminate\Auth\SessionGuard
'
, [
'
user
'
], [
'
default
'
,
$
provider
,
$
session
,
$
request
]);
$
mock
->
expects
(
$
this
->
exactly
(
2
))->
method
(
'
user
'
)->
will
(
$
this
->
returnValue
(
null
));
$
this
->
assertFalse
(
$
mock
->
check
());
$
this
->
assertTrue
(
$
mock
->
guest
());
}
public
function
testUserMethodReturnsCachedUser
()
{
$
user
= m::
mock
(
'
Illuminate\Contracts\Auth\Authenticatable
'
);
$
mock
=
$
this
->
getGuard
();
$
mock
->
setUser
(
$
user
);
$
this
->
assertEquals
(
$
user
,
$
mock
->
user
());
}
public
function
testNullIsReturnedForUserIfNoUserFound
()
{
$
mock
=
$
this
->
getGuard
();
$
mock
->
getSession
()->
shouldReceive
(
'
get
'
)->
once
()->
andReturn
(
null
);
$
this
->
assertNull
(
$
mock
->
user
());
}
public
function
testUserIsSetToRetrievedUser
()
{
$
mock
=
$
this
->
getGuard
();
$
mock
->
getSession
()->
shouldReceive
(
'
get
'
)->
once
()->
andReturn
(
1
);
$
user
= m::
mock
(
'
Illuminate\Contracts\Auth\Authenticatable
'
);
$
mock
->
getProvider
()->
shouldReceive
(
'
retrieveById
'
)->
once
()->
with
(
1
)->
andReturn
(
$
user
);
$
this
->
assertEquals
(
$
user
,
$
mock
->
user
());
$
this
->
assertEquals
(
$
user
,
$
mock
->
getUser
());
}
public
function
testLogoutRemovesSessionTokenAndRememberMeCookie
()
{
list
(
$
session
,
$
provider
,
$
request
,
$
cookie
) =
$
this
->
getMocks
();
$
mock
=
$
this
->
getMock
(
'
Illuminate\Auth\SessionGuard
'
, [
'
getName
'
,
'
getRecallerName
'
,
'
getRecaller
'
], [
'
default
'
,
$
provider
,
$
session
,
$
request
]);
$
mock
->
setCookieJar
(
$
cookies
= m::
mock
(
'
Illuminate\Cookie\CookieJar
'
));
$
user
= m::
mock
(
'
Illuminate\Contracts\Auth\Authenticatable
'
);
$
user
->
shouldReceive
(
'
setRememberToken
'
)->
once
();
$
mock
->
expects
(
$
this
->
once
())->
method
(
'
getName
'
)->
will
(
$
this
->
returnValue
(
'
foo
'
));
$
mock
->
expects
(
$
this
->
once
())->
method
(
'
getRecallerName
'
)->
will
(
$
this
->
returnValue
(
'
bar
'
));
$
mock
->
expects
(
$
this
->
once
())->
method
(
'
getRecaller
'
)->
will
(
$
this
->
returnValue
(
'
non-null-cookie
'
));
$
provider
->
shouldReceive
(
'
updateRememberToken
'
)->
once
();
$
cookie
= m::
mock
(
'
Symfony\Component\HttpFoundation\Cookie
'
);
$
cookies
->
shouldReceive
(
'
forget
'
)->
once
()->
with
(
'
bar
'
)->
andReturn
(
$
cookie
);
$
cookies
->
shouldReceive
(
'
queue
'
)->
once
()->
with
(
$
cookie
);
$
mock
->
getSession
()->
shouldReceive
(
'
remove
'
)->
once
()->
with
(
'
foo
'
);
$
mock
->
setUser
(
$
user
);
$
mock
->
logout
();
$
this
->
assertNull
(
$
mock
->
getUser
());
}
public
function
testLogoutDoesNotEnqueueRememberMeCookieForDeletionIfCookieDoesntExist
()
{
list
(
$
session
,
$
provider
,
$
request
,
$
cookie
) =
$
this
->
getMocks
();
$
mock
=
$
this
->
getMock
(
'
Illuminate\Auth\SessionGuard
'
, [
'
getName
'
,
'
getRecaller
'
], [
'
default
'
,
$
provider
,
$
session
,
$
request
]);
$
mock
->
setCookieJar
(
$
cookies
= m::
mock
(
'
Illuminate\Cookie\CookieJar
'
));
$
user
= m::
mock
(
'
Illuminate\Contracts\Auth\Authenticatable
'
);
$
user
->
shouldReceive
(
'
setRememberToken
'
)->
once
();
$
mock
->
expects
(
$
this
->
once
())->
method
(
'
getName
'
)->
will
(
$
this
->
returnValue
(
'
foo
'
));
$
mock
->
expects
(
$
this
->
once
())->
method
(
'
getRecaller
'
)->
will
(
$
this
->
returnValue
(
null
));
$
provider
->
shouldReceive
(
'
updateRememberToken
'
)->
once
();
$
mock
->
getSession
()->
shouldReceive
(
'
remove
'
)->
once
()->
with
(
'
foo
'
);
$
mock
->
setUser
(
$
user
);
$
mock
->
logout
();
$
this
->
assertNull
(
$
mock
->
getUser
());
}
public
function
testLogoutFiresLogoutEvent
()
{
list
(
$
session
,
$
provider
,
$
request
,
$
cookie
) =
$
this
->
getMocks
();
$
mock
=
$
this
->
getMock
(
'
Illuminate\Auth\SessionGuard
'
, [
'
clearUserDataFromStorage
'
], [
'
default
'
,
$
provider
,
$
session
,
$
request
]);
$
mock
->
expects
(
$
this
->
once
())->
method
(
'
clearUserDataFromStorage
'
);
$
mock
->
setDispatcher
(
$
events
= m::
mock
(
'
Illuminate\Contracts\Events\Dispatcher
'
));
$
user
= m::
mock
(
'
Illuminate\Contracts\Auth\Authenticatable
'
);
$
user
->
shouldReceive
(
'
setRememberToken
'
)->
once
();
$
provider
->
shouldReceive
(
'
updateRememberToken
'
)->
once
();
$
mock
->
setUser
(
$
user
);
$
events
->
shouldReceive
(
'
fire
'
)->
once
()->
with
(m::
type
(
'
Illuminate\Auth\Events\Logout
'
));
$
mock
->
logout
();
}
public
function
testLoginMethodQueuesCookieWhenRemembering
()
{
list
(
$
session
,
$
provider
,
$
request
,
$
cookie
) =
$
this
->
getMocks
();
$
guard
=
new
Illuminate
\
Auth
\
SessionGuard
(
'
default
'
,
$
provider
,
$
session
,
$
request
);
$
guard
->
setCookieJar
(
$
cookie
);
$
foreverCookie
=
new
Symfony
\
Component
\
HttpFoundation
\
Cookie
(
$
guard
->
getRecallerName
(),
'
foo
'
);
$
cookie
->
shouldReceive
(
'
forever
'
)->
once
()->
with
(
$
guard
->
getRecallerName
(),
'
foo|recaller
'
)->
andReturn
(
$
foreverCookie
);
$
cookie
->
shouldReceive
(
'
queue
'
)->
once
()->
with
(
$
foreverCookie
);
$
guard
->
getSession
()->
shouldReceive
(
'
set
'
)->
once
()->
with
(
$
guard
->
getName
(),
'
foo
'
);
$
session
->
shouldReceive
(
'
migrate
'
)->
once
();
$
user
= m::
mock
(
'
Illuminate\Contracts\Auth\Authenticatable
'
);
$
user
->
shouldReceive
(
'
getAuthIdentifier
'
)->
andReturn
(
'
foo
'
);
$
user
->
shouldReceive
(
'
getRememberToken
'
)->
andReturn
(
'
recaller
'
);
$
user
->
shouldReceive
(
'
setRememberToken
'
)->
never
();
$
provider
->
shouldReceive
(
'
updateRememberToken
'
)->
never
();
$
guard
->
login
(
$
user
,
true
);
}
public
function
testLoginMethodCreatesRememberTokenIfOneDoesntExist
()
{
list
(
$
session
,
$
provider
,
$
request
,
$
cookie
) =
$
this
->
getMocks
();
$
guard
=
new
Illuminate
\
Auth
\
SessionGuard
(
'
default
'
,
$
provider
,
$
session
,
$
request
);
$
guard
->
setCookieJar
(
$
cookie
);
$
foreverCookie
=
new
Symfony
\
Component
\
HttpFoundation
\
Cookie
(
$
guard
->
getRecallerName
(),
'
foo
'
);
$
cookie
->
shouldReceive
(
'
forever
'
)->
once
()->
andReturn
(
$
foreverCookie
);
$
cookie
->
shouldReceive
(
'
queue
'
)->
once
()->
with
(
$
foreverCookie
);
$
guard
->
getSession
()->
shouldReceive
(
'
set
'
)->
once
()->
with
(
$
guard
->
getName
(),
'
foo
'
);
$
session
->
shouldReceive
(
'
migrate
'
)->
once
();
$
user
= m::
mock
(
'
Illuminate\Contracts\Auth\Authenticatable
'
);
$
user
->
shouldReceive
(
'
getAuthIdentifier
'
)->
andReturn
(
'
foo
'
);
$
user
->
shouldReceive
(
'
getRememberToken
'
)->
andReturn
(
null
);
$
user
->
shouldReceive
(
'
setRememberToken
'
)->
once
();
$
provider
->
shouldReceive
(
'
updateRememberToken
'
)->
once
();
$
guard
->
login
(
$
user
,
true
);
}
public
function
testLoginUsingIdStoresInSessionAndLogsInWithUser
()
{
list
(
$
session
,
$
provider
,
$
request
,
$
cookie
) =
$
this
->
getMocks
();
$
guard
=
$
this
->
getMock
(
'
Illuminate\Auth\SessionGuard
'
, [
'
login
'
,
'
user
'
], [
'
default
'
,
$
provider
,
$
session
,
$
request
]);
$
guard
->
getSession
()->
shouldReceive
(
'
set
'
)->
once
()->
with
(
$
guard
->
getName
(),
10
);
$
guard
->
getProvider
()->
shouldReceive
(
'
retrieveById
'
)->
once
()->
with
(
10
)->
andReturn
(
$
user
= m::
mock
(
'
Illuminate\Contracts\Auth\Authenticatable
'
));
$
guard
->
expects
(
$
this
->
once
())->
method
(
'
login
'
)->
with
(
$
this
->
equalTo
(
$
user
),
$
this
->
equalTo
(
false
))->
will
(
$
this
->
returnValue
(
$
user
));
$
this
->
assertEquals
(
$
user
,
$
guard
->
loginUsingId
(
10
));
}
public
function
testOnceUsingIdFailure
()
{
$
guard
=
$
this
->
getGuard
();
$
guard
->
getProvider
()->
shouldReceive
(
'
retrieveById
'
)->
once
()->
with
(
11
)->
andReturn
(
null
);
$
this
->
assertFalse
(
$
guard
->
onceUsingId
(
11
));
}
public
function
testUserUsesRememberCookieIfItExists
()
{
$
guard
=
$
this
->
getGuard
();
list
(
$
session
,
$
provider
,
$
request
,
$
cookie
) =
$
this
->
getMocks
();
$
request
=
Symfony
\
Component
\
HttpFoundation
\Request::
create
(
'
/
'
,
'
GET
'
, [], [
$
guard
->
getRecallerName
() =>
'
id|recaller
'
]);
$
guard
=
new
Illuminate
\
Auth
\
SessionGuard
(
'
default
'
,
$
provider
,
$
session
,
$
request
);
$
guard
->
getSession
()->
shouldReceive
(
'
get
'
)->
once
()->
with
(
$
guard
->
getName
())->
andReturn
(
null
);
$
user
= m::
mock
(
'
Illuminate\Contracts\Auth\Authenticatable
'
);
$
guard
->
getProvider
()->
shouldReceive
(
'
retrieveByToken
'
)->
once
()->
with
(
'
id
'
,
'
recaller
'
)->
andReturn
(
$
user
);
$
user
->
shouldReceive
(
'
getAuthIdentifier
'
)->
once
()->
andReturn
(
'
bar
'
);
$
guard
->
getSession
()->
shouldReceive
(
'
set
'
)->
with
(
$
guard
->
getName
(),
'
bar
'
)->
once
();
$
session
->
shouldReceive
(
'
migrate
'
)->
once
();
$
this
->
assertEquals
(
$
user
,
$
guard
->
user
());
$
this
->
assertTrue
(
$
guard
->
viaRemember
());
}
protected
function
getGuard
()
{
list
(
$
session
,
$
provider
,
$
request
,
$
cookie
) =
$
this
->
getMocks
();
return
new
Illuminate
\
Auth
\
SessionGuard
(
'
default
'
,
$
provider
,
$
session
,
$
request
);
}
protected
function
getMocks
()
{
return
[
m::
mock
(
'
Symfony\Component\HttpFoundation\Session\SessionInterface
'
),
m::
mock
(
'
Illuminate\Contracts\Auth\UserProvider
'
),
Symfony
\
Component
\
HttpFoundation
\Request::
create
(
'
/
'
,
'
GET
'
),
m::
mock
(
'
Illuminate\Cookie\CookieJar
'
),
];
}
protected
function
getCookieJar
()
{
return
new
Illuminate
\
Cookie
\
CookieJar
(Request::
create
(
'
/foo
'
,
'
GET
'
), m::
mock
(
'
Illuminate\Contracts\Encryption\Encrypter
'
), [
'
domain
'
=>
'
foo.com
'
,
'
path
'
=>
'
/
'
,
'
secure
'
=>
false
,
'
httpOnly
'
=>
false
]);
}
}
Back
|
FazBrowse Home
|
New Git URL