summaryrefslogtreecommitdiffstats
path: root/Tests/Http/RememberMe/AbstractRememberMeServicesTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'Tests/Http/RememberMe/AbstractRememberMeServicesTest.php')
-rw-r--r--Tests/Http/RememberMe/AbstractRememberMeServicesTest.php32
1 files changed, 29 insertions, 3 deletions
diff --git a/Tests/Http/RememberMe/AbstractRememberMeServicesTest.php b/Tests/Http/RememberMe/AbstractRememberMeServicesTest.php
index 70ff6a0..9dbcf3f 100644
--- a/Tests/Http/RememberMe/AbstractRememberMeServicesTest.php
+++ b/Tests/Http/RememberMe/AbstractRememberMeServicesTest.php
@@ -82,16 +82,35 @@ class AbstractRememberMeServicesTest extends \PHPUnit_Framework_TestCase
$this->assertSame('fookey', $returnedToken->getProviderKey());
}
- public function testLogout()
+ /**
+ * @dataProvider provideOptionsForLogout
+ */
+ public function testLogout(array $options)
{
- $service = $this->getService(null, array('name' => 'foo', 'path' => null, 'domain' => null));
+ $service = $this->getService(null, $options);
$request = new Request();
$response = new Response();
$token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
$service->logout($request, $response, $token);
- $this->assertTrue($request->attributes->get(RememberMeServicesInterface::COOKIE_ATTR_NAME)->isCleared());
+ $cookie = $request->attributes->get(RememberMeServicesInterface::COOKIE_ATTR_NAME);
+
+ $this->assertInstanceOf('Symfony\Component\HttpFoundation\Cookie', $cookie);
+ $this->assertTrue($cookie->isCleared());
+ $this->assertSame($options['name'], $cookie->getName());
+ $this->assertSame($options['path'], $cookie->getPath());
+ $this->assertSame($options['domain'], $cookie->getDomain());
+ $this->assertSame($options['secure'], $cookie->isSecure());
+ $this->assertSame($options['httponly'], $cookie->isHttpOnly());
+ }
+
+ public function provideOptionsForLogout()
+ {
+ return array(
+ array(array('name' => 'foo', 'path' => '/', 'domain' => null, 'secure' => false, 'httponly' => true)),
+ array(array('name' => 'foo', 'path' => '/bar', 'domain' => 'baz.com', 'secure' => true, 'httponly' => false)),
+ );
}
public function testLoginFail()
@@ -267,6 +286,13 @@ class AbstractRememberMeServicesTest extends \PHPUnit_Framework_TestCase
$userProvider = $this->getProvider();
}
+ if (!isset($options['secure'])) {
+ $options['secure'] = false;
+ }
+ if (!isset($options['httponly'])) {
+ $options['httponly'] = true;
+ }
+
return $this->getMockForAbstractClass('Symfony\Component\Security\Http\RememberMe\AbstractRememberMeServices', array(
array($userProvider), 'fookey', 'fookey', $options, $logger,
));