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
c24b35a5
Commit
c24b35a5
authored
Mar 29, 2011
by
Igor Wiedler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[SessionExtension] initial test case
parent
c642d13b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
0 deletions
+58
-0
tests/Silex/Tests/Extension/SessionExtensionTest.php
tests/Silex/Tests/Extension/SessionExtensionTest.php
+58
-0
No files found.
tests/Silex/Tests/Extension/SessionExtensionTest.php
0 → 100644
View file @
c24b35a5
<?php
/*
* This file is part of the Silex framework.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace
Silex\Tests
;
use
Silex\Application
;
use
Silex\Extension\SessionExtension
;
use
Symfony\Component\HttpFoundation\Request
;
use
Symfony\Component\HttpFoundation\SessionStorage\ArraySessionStorage
;
/**
* SessionExtension test cases.
*
* @author Igor Wiedler <igor@wiedler.ch>
*/
class
SessionExtensionTest
extends
\PHPUnit_Framework_TestCase
{
public
function
testRegister
()
{
$app
=
new
Application
();
$app
->
register
(
new
SessionExtension
());
$app
[
'session.storage'
]
=
$app
->
share
(
function
()
use
(
$app
)
{
return
new
ArraySessionStorage
();
});
$app
->
get
(
'/login'
,
function
()
use
(
$app
)
{
$app
[
'session'
]
->
set
(
'logged_in'
,
true
);
return
'Logged in successfully.'
;
});
$app
->
get
(
'/account'
,
function
()
use
(
$app
)
{
if
(
!
$app
[
'session'
]
->
get
(
'logged_in'
))
{
return
'You are not in.'
;
}
return
'This is your account.'
;
});
$request
=
Request
::
create
(
'/login'
);
$response
=
$app
->
handle
(
$request
);
$this
->
assertEquals
(
'Logged in successfully.'
,
$response
->
getContent
());
$request
=
Request
::
create
(
'/account'
);
$response
=
$app
->
handle
(
$request
);
$this
->
assertEquals
(
'This is your account.'
,
$response
->
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