Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
S
Silex
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
common
Silex
Commits
55dce6b5
Commit
55dce6b5
authored
Dec 17, 2012
by
Romain Neutron
Committed by
Fabien Potencier
Dec 18, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test session service provider with routes that does not use session
parent
c2dff3ca
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
3 deletions
+31
-3
src/Silex/Provider/SessionServiceProvider.php
src/Silex/Provider/SessionServiceProvider.php
+2
-1
tests/Silex/Tests/Provider/SessionServiceProviderTest.php
tests/Silex/Tests/Provider/SessionServiceProviderTest.php
+29
-2
No files found.
src/Silex/Provider/SessionServiceProvider.php
View file @
55dce6b5
...
...
@@ -103,7 +103,8 @@ class SessionServiceProvider implements ServiceProviderInterface
return
;
}
if
(
$session
=
$event
->
getRequest
()
->
getSession
())
{
$session
=
$event
->
getRequest
()
->
getSession
();
if
(
$session
&&
$session
->
isStarted
())
{
$session
->
save
();
$params
=
session_get_cookie_params
();
...
...
tests/Silex/Tests/Provider/SessionServiceProviderTest.php
View file @
55dce6b5
...
...
@@ -14,8 +14,7 @@ namespace Silex\Tests\Provider;
use
Silex\Application
;
use
Silex\WebTestCase
;
use
Silex\Provider\SessionServiceProvider
;
use
Symfony\Component\HttpFoundation\Request
;
use
Symfony\Component\HttpKernel\Client
;
/**
* SessionProvider test cases.
...
...
@@ -77,4 +76,32 @@ class SessionServiceProviderTest extends WebTestCase
return
$app
;
}
public
function
testWithRoutesThatDoesNotUseSession
()
{
$app
=
new
Application
();
$app
->
register
(
new
SessionServiceProvider
(),
array
(
'session.test'
=>
true
,
));
$app
->
get
(
'/'
,
function
()
{
return
'A welcome page.'
;
});
$app
->
get
(
'/robots.txt'
,
function
()
{
return
'Informations for robots.'
;
});
$app
[
'debug'
]
=
true
;
$app
[
'exception_handler'
]
->
disable
();
$client
=
new
Client
(
$app
);
$client
->
request
(
'get'
,
'/'
);
$this
->
assertEquals
(
'A welcome page.'
,
$client
->
getResponse
()
->
getContent
());
$client
->
request
(
'get'
,
'/robots.txt'
);
$this
->
assertEquals
(
'Informations for robots.'
,
$client
->
getResponse
()
->
getContent
());
}
}
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