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
c1e68717
Commit
c1e68717
authored
Oct 11, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
working more on tests.
parent
bb77189f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
7 deletions
+49
-7
SessionManagerTest.php
tests/Cases/Session/SessionManagerTest.php
+48
-7
SessionPayloadTest.php
tests/Cases/Session/SessionPayloadTest.php
+1
-0
No files found.
tests/Cases/Session/SessionManagerTest.php
View file @
c1e68717
...
@@ -11,7 +11,9 @@ class SessionManagerTest extends PHPUnit_Framework_TestCase {
...
@@ -11,7 +11,9 @@ class SessionManagerTest extends PHPUnit_Framework_TestCase {
public
function
test_session_manager_calls_transporter_get
(
$driver
,
$transporter
)
public
function
test_session_manager_calls_transporter_get
(
$driver
,
$transporter
)
{
{
$transporter
->
expects
(
$this
->
once
())
->
method
(
'get'
);
$transporter
->
expects
(
$this
->
once
())
->
method
(
'get'
);
$manager
=
new
Manager
(
$driver
,
$transporter
);
$manager
=
new
Manager
(
$driver
,
$transporter
);
$manager
->
payload
(
$this
->
getConfig
());
$manager
->
payload
(
$this
->
getConfig
());
}
}
...
@@ -20,9 +22,16 @@ class SessionManagerTest extends PHPUnit_Framework_TestCase {
...
@@ -20,9 +22,16 @@ class SessionManagerTest extends PHPUnit_Framework_TestCase {
*/
*/
public
function
test_session_manager_calls_driver_load_with_session_id
(
$driver
,
$transporter
)
public
function
test_session_manager_calls_driver_load_with_session_id
(
$driver
,
$transporter
)
{
{
$transporter
->
expects
(
$this
->
any
())
->
method
(
'get'
)
->
will
(
$this
->
returnValue
(
'something'
));
$transporter
->
expects
(
$this
->
any
())
$driver
->
expects
(
$this
->
once
())
->
method
(
'load'
)
->
with
(
$this
->
equalTo
(
'something'
));
->
method
(
'get'
)
->
will
(
$this
->
returnValue
(
'something'
));
$driver
->
expects
(
$this
->
once
())
->
method
(
'load'
)
->
with
(
$this
->
equalTo
(
'something'
));
$manager
=
new
Manager
(
$driver
,
$transporter
);
$manager
=
new
Manager
(
$driver
,
$transporter
);
$manager
->
payload
(
$this
->
getConfig
());
$manager
->
payload
(
$this
->
getConfig
());
}
}
...
@@ -32,8 +41,10 @@ class SessionManagerTest extends PHPUnit_Framework_TestCase {
...
@@ -32,8 +41,10 @@ class SessionManagerTest extends PHPUnit_Framework_TestCase {
public
function
test_session_manager_returns_payload_when_found
(
$driver
,
$transporter
)
public
function
test_session_manager_returns_payload_when_found
(
$driver
,
$transporter
)
{
{
$this
->
setDriverExpectation
(
$driver
,
'load'
,
$this
->
getDummySession
());
$this
->
setDriverExpectation
(
$driver
,
'load'
,
$this
->
getDummySession
());
$manager
=
new
Manager
(
$driver
,
$transporter
);
$manager
=
new
Manager
(
$driver
,
$transporter
);
$payload
=
$manager
->
payload
(
$this
->
getConfig
());
$payload
=
$manager
->
payload
(
$this
->
getConfig
());
$this
->
assertInstanceOf
(
'Laravel\\Session\\Payload'
,
$payload
);
$this
->
assertInstanceOf
(
'Laravel\\Session\\Payload'
,
$payload
);
$this
->
assertEquals
(
$payload
->
session
,
$this
->
getDummySession
());
$this
->
assertEquals
(
$payload
->
session
,
$this
->
getDummySession
());
}
}
...
@@ -44,8 +55,10 @@ class SessionManagerTest extends PHPUnit_Framework_TestCase {
...
@@ -44,8 +55,10 @@ class SessionManagerTest extends PHPUnit_Framework_TestCase {
public
function
test_session_manager_creates_new_session_when_session_is_null
(
$driver
,
$transporter
)
public
function
test_session_manager_creates_new_session_when_session_is_null
(
$driver
,
$transporter
)
{
{
$this
->
setDriverExpectation
(
$driver
,
'load'
,
null
);
$this
->
setDriverExpectation
(
$driver
,
'load'
,
null
);
$manager
=
new
Manager
(
$driver
,
$transporter
);
$manager
=
new
Manager
(
$driver
,
$transporter
);
$payload
=
$manager
->
payload
(
$this
->
getConfig
());
$payload
=
$manager
->
payload
(
$this
->
getConfig
());
$this
->
assertInstanceOf
(
'Laravel\\Session\\Payload'
,
$payload
);
$this
->
assertInstanceOf
(
'Laravel\\Session\\Payload'
,
$payload
);
$this
->
assertEquals
(
strlen
(
$payload
->
session
[
'id'
]),
40
);
$this
->
assertEquals
(
strlen
(
$payload
->
session
[
'id'
]),
40
);
$this
->
assertTrue
(
is_array
(
$payload
->
session
[
'data'
]));
$this
->
assertTrue
(
is_array
(
$payload
->
session
[
'data'
]));
...
@@ -58,8 +71,10 @@ class SessionManagerTest extends PHPUnit_Framework_TestCase {
...
@@ -58,8 +71,10 @@ class SessionManagerTest extends PHPUnit_Framework_TestCase {
{
{
$dateTime
=
new
DateTime
(
'1970-01-01'
);
$dateTime
=
new
DateTime
(
'1970-01-01'
);
$this
->
setDriverExpectation
(
$driver
,
'load'
,
array
(
'last_activity'
=>
$dateTime
->
getTimestamp
()));
$this
->
setDriverExpectation
(
$driver
,
'load'
,
array
(
'last_activity'
=>
$dateTime
->
getTimestamp
()));
$manager
=
new
Manager
(
$driver
,
$transporter
);
$manager
=
new
Manager
(
$driver
,
$transporter
);
$payload
=
$manager
->
payload
(
$this
->
getConfig
());
$payload
=
$manager
->
payload
(
$this
->
getConfig
());
$this
->
assertInstanceOf
(
'Laravel\\Session\\Payload'
,
$payload
);
$this
->
assertInstanceOf
(
'Laravel\\Session\\Payload'
,
$payload
);
$this
->
assertEquals
(
strlen
(
$payload
->
session
[
'id'
]),
40
);
$this
->
assertEquals
(
strlen
(
$payload
->
session
[
'id'
]),
40
);
}
}
...
@@ -72,8 +87,10 @@ class SessionManagerTest extends PHPUnit_Framework_TestCase {
...
@@ -72,8 +87,10 @@ class SessionManagerTest extends PHPUnit_Framework_TestCase {
$session
=
$this
->
getDummySession
();
$session
=
$this
->
getDummySession
();
unset
(
$session
[
'data'
][
'csrf_token'
]);
unset
(
$session
[
'data'
][
'csrf_token'
]);
$this
->
setDriverExpectation
(
$driver
,
'load'
,
$session
);
$this
->
setDriverExpectation
(
$driver
,
'load'
,
$session
);
$manager
=
new
Manager
(
$driver
,
$transporter
);
$manager
=
new
Manager
(
$driver
,
$transporter
);
$payload
=
$manager
->
payload
(
$this
->
getConfig
());
$payload
=
$manager
->
payload
(
$this
->
getConfig
());
$this
->
assertTrue
(
isset
(
$payload
->
session
[
'data'
][
'csrf_token'
]));
$this
->
assertTrue
(
isset
(
$payload
->
session
[
'data'
][
'csrf_token'
]));
$this
->
assertEquals
(
strlen
(
$payload
->
session
[
'data'
][
'csrf_token'
]),
16
);
$this
->
assertEquals
(
strlen
(
$payload
->
session
[
'data'
][
'csrf_token'
]),
16
);
}
}
...
@@ -83,12 +100,30 @@ class SessionManagerTest extends PHPUnit_Framework_TestCase {
...
@@ -83,12 +100,30 @@ class SessionManagerTest extends PHPUnit_Framework_TestCase {
*/
*/
public
function
test_close_method_calls_driver_and_transporter
(
$driver
,
$transporter
)
public
function
test_close_method_calls_driver_and_transporter
(
$driver
,
$transporter
)
{
{
$driver
->
expects
(
$this
->
any
())
->
method
(
'load'
)
->
will
(
$this
->
returnValue
(
$this
->
getDummySession
()));
$driver
->
expects
(
$this
->
any
())
->
method
(
'load'
)
->
will
(
$this
->
returnValue
(
$this
->
getDummySession
()));
$manager
=
new
Manager
(
$driver
,
$transporter
);
$manager
=
new
Manager
(
$driver
,
$transporter
);
$payload
=
$this
->
getMock
(
'Laravel\\Session\\Payload'
,
array
(
'age'
),
array
(
array
(
'id'
=>
'something'
)));
$payload
->
expects
(
$this
->
any
())
->
method
(
'age'
)
->
will
(
$this
->
returnValue
(
'something'
));
$payload
=
$this
->
getMock
(
$driver
->
expects
(
$this
->
once
())
->
method
(
'save'
)
->
with
(
'something'
,
$this
->
getConfig
());
'Laravel\\Session\\Payload'
,
$transporter
->
expects
(
$this
->
once
())
->
method
(
'put'
)
->
with
(
'something'
,
$this
->
getConfig
());
array
(
'age'
),
array
(
array
(
'id'
=>
'something'
))
);
$payload
->
expects
(
$this
->
any
())
->
method
(
'age'
)
->
will
(
$this
->
returnValue
(
'something'
));
$driver
->
expects
(
$this
->
once
())
->
method
(
'save'
)
->
with
(
'something'
,
$this
->
getConfig
());
$transporter
->
expects
(
$this
->
once
())
->
method
(
'put'
)
->
with
(
'something'
,
$this
->
getConfig
());
$manager
->
close
(
$payload
,
$this
->
getConfig
());
$manager
->
close
(
$payload
,
$this
->
getConfig
());
}
}
...
@@ -99,9 +134,12 @@ class SessionManagerTest extends PHPUnit_Framework_TestCase {
...
@@ -99,9 +134,12 @@ class SessionManagerTest extends PHPUnit_Framework_TestCase {
{
{
$driver
=
$this
->
getMock
(
'SweeperStub'
,
array
(
'sweep'
));
$driver
=
$this
->
getMock
(
'SweeperStub'
,
array
(
'sweep'
));
$driver
->
expects
(
$this
->
once
())
->
method
(
'sweep'
);
$driver
->
expects
(
$this
->
once
())
->
method
(
'sweep'
);
$manager
=
new
Manager
(
$driver
,
$transporter
);
$manager
=
new
Manager
(
$driver
,
$transporter
);
$config
=
$this
->
getConfig
();
$config
=
$this
->
getConfig
();
$config
[
'sweepage'
]
=
array
(
100
,
100
);
$config
[
'sweepage'
]
=
array
(
100
,
100
);
$manager
->
close
(
new
Laravel\Session\Payload
(
$this
->
getDummySession
()),
$config
);
$manager
->
close
(
new
Laravel\Session\Payload
(
$this
->
getDummySession
()),
$config
);
}
}
...
@@ -112,9 +150,12 @@ class SessionManagerTest extends PHPUnit_Framework_TestCase {
...
@@ -112,9 +150,12 @@ class SessionManagerTest extends PHPUnit_Framework_TestCase {
{
{
$driver
=
$this
->
getMock
(
'Laravel\\Session\\Drivers\\Driver'
,
array
(
'sweep'
,
'load'
,
'save'
,
'delete'
));
$driver
=
$this
->
getMock
(
'Laravel\\Session\\Drivers\\Driver'
,
array
(
'sweep'
,
'load'
,
'save'
,
'delete'
));
$driver
->
expects
(
$this
->
never
())
->
method
(
'sweep'
);
$driver
->
expects
(
$this
->
never
())
->
method
(
'sweep'
);
$manager
=
new
Manager
(
$driver
,
$transporter
);
$manager
=
new
Manager
(
$driver
,
$transporter
);
$config
=
$this
->
getConfig
();
$config
=
$this
->
getConfig
();
$config
[
'sweepage'
]
=
array
(
100
,
100
);
$config
[
'sweepage'
]
=
array
(
100
,
100
);
$manager
->
close
(
new
Laravel\Session\Payload
(
$this
->
getDummySession
()),
$config
);
$manager
->
close
(
new
Laravel\Session\Payload
(
$this
->
getDummySession
()),
$config
);
}
}
...
...
tests/Cases/Session/SessionPayloadTest.php
View file @
c1e68717
...
@@ -65,6 +65,7 @@ class SessionPayloadTest extends PHPUnit_Framework_TestCase {
...
@@ -65,6 +65,7 @@ class SessionPayloadTest extends PHPUnit_Framework_TestCase {
$payload
->
keep
(
'name'
);
$payload
->
keep
(
'name'
);
$this
->
assertTrue
(
isset
(
$payload
->
session
[
'data'
][
':new:name'
]));
$this
->
assertTrue
(
isset
(
$payload
->
session
[
'data'
][
':new:name'
]));
$this
->
assertFalse
(
isset
(
$payload
->
session
[
'data'
][
':old:name'
]));
$this
->
assertFalse
(
isset
(
$payload
->
session
[
'data'
][
':old:name'
]));
$payload
=
new
Payload
(
array
(
'data'
=>
array
(
':old:name'
=>
'Taylor'
,
':old:age'
=>
25
)));
$payload
=
new
Payload
(
array
(
'data'
=>
array
(
':old:name'
=>
'Taylor'
,
':old:age'
=>
25
)));
$payload
->
keep
(
array
(
'name'
,
'age'
));
$payload
->
keep
(
array
(
'name'
,
'age'
));
$this
->
assertTrue
(
isset
(
$payload
->
session
[
'data'
][
':new:name'
]));
$this
->
assertTrue
(
isset
(
$payload
->
session
[
'data'
][
':new:name'
]));
...
...
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