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
95023886
Commit
95023886
authored
Jan 15, 2015
by
SofHad
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests
parent
ed8423b9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
0 deletions
+44
-0
tests/Silex/Tests/Application/SecurityTraitTest.php
tests/Silex/Tests/Application/SecurityTraitTest.php
+44
-0
No files found.
tests/Silex/Tests/Application/SecurityTraitTest.php
View file @
95023886
...
...
@@ -40,6 +40,50 @@ class SecurityTraitTest extends \PHPUnit_Framework_TestCase
$this
->
assertEquals
(
'fabien'
,
$app
->
user
()
->
getUsername
());
}
public
function
testUserWithNoToken
()
{
$request
=
Request
::
create
(
'/'
);
$app
=
new
SecurityApplication
();
$app
[
'security'
]
=
$this
->
getMockBuilder
(
'Symfony\Component\Security\Core\SecurityContext'
)
->
disableOriginalConstructor
()
->
getMock
();
$app
[
'security'
]
->
expects
(
$this
->
any
())
->
method
(
'getToken'
)
->
will
(
$this
->
returnValue
(
null
));
$app
->
get
(
'/'
,
function
()
{
return
'foo'
;
});
$app
->
handle
(
$request
);
$this
->
assertNull
(
$app
->
user
());
}
public
function
testUserWithInvalidUser
()
{
$request
=
Request
::
create
(
'/'
);
$app
=
new
SecurityApplication
();
$app
[
'security'
]
=
$this
->
getMockBuilder
(
'Symfony\Component\Security\Core\SecurityContext'
)
->
disableOriginalConstructor
()
->
getMock
();
$token
=
$this
->
getMockBuilder
(
'Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken'
)
->
disableOriginalConstructor
()
->
getMock
();
$token
->
expects
(
$this
->
once
())
->
method
(
'getUser'
)
->
will
(
$this
->
returnValue
(
array
()));
$app
[
'security'
]
->
expects
(
$this
->
any
())
->
method
(
'getToken'
)
->
will
(
$this
->
returnValue
(
$token
));
$app
->
get
(
'/'
,
function
()
{
return
'foo'
;
});
$app
->
handle
(
$request
);
$this
->
assertNull
(
$app
->
user
());
}
public
function
testEncodePassword
()
{
$app
=
$this
->
createApplication
();
...
...
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