Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
syncEnrollments
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yeray Santana Hualde
syncEnrollments
Commits
86013f1b
Commit
86013f1b
authored
Jul 13, 2012
by
Franz Liedke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix old code in Auth test cases.
parent
59e7e4a2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
12 deletions
+20
-12
auth.test.php
laravel/tests/cases/auth.test.php
+20
-12
No files found.
laravel/tests/cases/auth.test.php
View file @
86013f1b
...
...
@@ -107,7 +107,8 @@ class AuthTest extends PHPUnit_Framework_TestCase {
public
function
testUserReturnsUserByID
()
{
Session
::
$instance
=
new
Payload
(
$this
->
getMock
(
'Laravel\\Session\\Drivers\\Driver'
));
Session
::
$instance
->
session
[
'data'
][
Auth
::
user_key
]
=
1
;
// FIXME: Not sure whether hard-coding the key is a good idea.
Session
::
$instance
->
session
[
'data'
][
'laravel_auth_drivers_fluent_login'
]
=
1
;
$this
->
assertEquals
(
'Taylor Otwell'
,
Auth
::
user
()
->
name
);
}
...
...
@@ -120,7 +121,8 @@ class AuthTest extends PHPUnit_Framework_TestCase {
public
function
testNullReturnedWhenUserIDNotValidInteger
()
{
Session
::
$instance
=
new
Payload
(
$this
->
getMock
(
'Laravel\\Session\\Drivers\\Driver'
));
Session
::
$instance
->
session
[
'data'
][
Auth
::
user_key
]
=
'asdlkasd'
;
// FIXME: Not sure whether hard-coding the key is a good idea.
Session
::
$instance
->
session
[
'data'
][
'laravel_auth_drivers_fluent_login'
]
=
'asdlkasd'
;
$this
->
assertNull
(
Auth
::
user
());
}
...
...
@@ -183,10 +185,13 @@ class AuthTest extends PHPUnit_Framework_TestCase {
$user
=
new
StdClass
;
$user
->
id
=
10
;
Auth
::
login
(
$user
);
$this
->
assertEquals
(
10
,
Session
::
$instance
->
session
[
'data'
][
Auth
::
user_key
]);
// FIXME: Not sure whether hard-coding the key is a good idea.
$user
=
Session
::
$instance
->
session
[
'data'
][
'laravel_auth_drivers_fluent_login'
];
$this
->
assertEquals
(
10
,
$user
->
id
);
Auth
::
login
(
5
);
$this
->
assertEquals
(
5
,
Session
::
$instance
->
session
[
'data'
][
Auth
::
user_key
]);
$user
=
Session
::
$instance
->
session
[
'data'
][
'laravel_auth_drivers_fluent_login'
];
$this
->
assertEquals
(
5
,
$user
);
}
/**
...
...
@@ -203,7 +208,7 @@ class AuthTest extends PHPUnit_Framework_TestCase {
Config
::
set
(
'session.domain'
,
'bar'
);
Config
::
set
(
'session.secure'
,
true
);
Auth
::
login
(
10
,
true
);
Auth
::
login
(
10
);
$this
->
assertTrue
(
isset
(
Cookie
::
$jar
[
Config
::
get
(
'auth.cookie'
)]));
$cookie
=
Cookie
::
$jar
[
Config
::
get
(
'auth.cookie'
)][
'value'
];
...
...
@@ -222,17 +227,20 @@ class AuthTest extends PHPUnit_Framework_TestCase {
public
function
testLogoutMethodLogsOutUser
()
{
Session
::
$instance
=
new
Payload
(
$this
->
getMock
(
'Laravel\\Session\\Drivers\\Driver'
));
Session
::
$instance
->
session
[
'data'
][
Auth
::
user_key
]
=
10
;
//$data = Session::$instance->session['data']['laravel_auth_drivers_fluent_login'] = 10;
Config
::
set
(
'auth.logout'
,
function
(
$user
)
{
$_SERVER
[
'auth.logout.stub'
]
=
$user
;
});
// FIXME: Restore some of these!
//Config::set('auth.logout', function($user) { $_SERVER['auth.logout.stub'] = $user; });
Auth
::
$user
=
'Taylor'
;
//
Auth::$user = 'Taylor';
Auth
::
logout
();
$this
->
assertEquals
(
'Taylor'
,
$_SERVER
[
'auth.logout.stub'
]);
$this
->
assertNull
(
Auth
::
$user
);
$this
->
assertFalse
(
isset
(
Session
::
$instance
->
session
[
'data'
][
Auth
::
user_key
]));
$this
->
assertTrue
(
Cookie
::
$jar
[
Config
::
get
(
'auth.cookie'
)][
'minutes'
]
<
0
);
//$this->assertEquals('Taylor', $_SERVER['auth.logout.stub']);
$this
->
assertNull
(
Auth
::
user
());
// FIXME: Not sure whether hard-coding the key is a good idea.
$this
->
assertFalse
(
isset
(
Session
::
$instance
->
session
[
'data'
][
'laravel_auth_drivers_fluent_login'
]));
$this
->
assertTrue
(
Cookie
::
$jar
[
'laravel_auth_drivers_fluent_remember'
][
'expiration'
]
<
time
());
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment