Commit 95023886 authored by SofHad's avatar SofHad

Add tests

parent ed8423b9
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment