summaryrefslogtreecommitdiffstats
path: root/Tests/Core/Authentication/RememberMe
diff options
context:
space:
mode:
authorFabien Potencier <fabien.potencier@gmail.com>2012-03-28 15:43:52 +0200
committerFabien Potencier <fabien.potencier@gmail.com>2012-03-29 08:37:22 +0200
commit21456eff7d574878255b8944594096bb56055e21 (patch)
treec57d4e85c78288e45dc748dd71e1a939eadf42f4 /Tests/Core/Authentication/RememberMe
parent57d74022db3d8c8a19330dad1c34d5d52d325184 (diff)
downloadsymfony-security-21456eff7d574878255b8944594096bb56055e21.zip
symfony-security-21456eff7d574878255b8944594096bb56055e21.tar.gz
symfony-security-21456eff7d574878255b8944594096bb56055e21.tar.bz2
moved component and bridge unit tests to the src/ directory
This is the first step to make each Symfony Component and Bridge self-contained.
Diffstat (limited to 'Tests/Core/Authentication/RememberMe')
-rw-r--r--Tests/Core/Authentication/RememberMe/InMemoryTokenProviderTest.php63
-rw-r--r--Tests/Core/Authentication/RememberMe/PersistentTokenTest.php29
2 files changed, 92 insertions, 0 deletions
diff --git a/Tests/Core/Authentication/RememberMe/InMemoryTokenProviderTest.php b/Tests/Core/Authentication/RememberMe/InMemoryTokenProviderTest.php
new file mode 100644
index 0000000..f6ec2a6
--- /dev/null
+++ b/Tests/Core/Authentication/RememberMe/InMemoryTokenProviderTest.php
@@ -0,0 +1,63 @@
+<?php
+
+/*
+ * This file is part of the Symfony 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 Symfony\Component\Security\Tests\Core\Authentication\RememberMe;
+
+use Symfony\Component\Security\Core\Authentication\RememberMe\PersistentToken;
+use Symfony\Component\Security\Core\Authentication\RememberMe\InMemoryTokenProvider;
+
+class InMemoryTokenProviderTest extends \PHPUnit_Framework_TestCase
+{
+ public function testCreateNewToken()
+ {
+ $provider = new InMemoryTokenProvider();
+
+ $token = new PersistentToken('foo', 'foo', 'foo', 'foo', new \DateTime());
+ $provider->createNewToken($token);
+
+ $this->assertSame($provider->loadTokenBySeries('foo'), $token);
+ }
+
+ /**
+ * @expectedException Symfony\Component\Security\Core\Exception\TokenNotFoundException
+ */
+ public function testLoadTokenBySeriesThrowsNotFoundException()
+ {
+ $provider = new InMemoryTokenProvider();
+ $provider->loadTokenBySeries('foo');
+ }
+
+ public function testUpdateToken()
+ {
+ $provider = new InMemoryTokenProvider();
+
+ $token = new PersistentToken('foo', 'foo', 'foo', 'foo', new \DateTime());
+ $provider->createNewToken($token);
+ $provider->updateToken('foo', 'newFoo', $lastUsed = new \DateTime());
+ $token = $provider->loadTokenBySeries('foo');
+
+ $this->assertEquals('newFoo', $token->getTokenValue());
+ $this->assertSame($token->getLastUsed(), $lastUsed);
+ }
+
+ /**
+ * @expectedException Symfony\Component\Security\Core\Exception\TokenNotFoundException
+ */
+ public function testDeleteToken()
+ {
+ $provider = new InMemoryTokenProvider();
+
+ $token = new PersistentToken('foo', 'foo', 'foo', 'foo', new \DateTime());
+ $provider->createNewToken($token);
+ $provider->deleteTokenBySeries('foo');
+ $provider->loadTokenBySeries('foo');
+ }
+}
diff --git a/Tests/Core/Authentication/RememberMe/PersistentTokenTest.php b/Tests/Core/Authentication/RememberMe/PersistentTokenTest.php
new file mode 100644
index 0000000..7336666
--- /dev/null
+++ b/Tests/Core/Authentication/RememberMe/PersistentTokenTest.php
@@ -0,0 +1,29 @@
+<?php
+
+/*
+ * This file is part of the Symfony 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 Symfony\Component\Security\Tests\Core\Authentication\RememberMe;
+
+use Symfony\Component\Security\Core\Authentication\RememberMe\PersistentToken;
+
+class PersistentTokenTest extends \PHPUnit_Framework_TestCase
+{
+ public function testConstructor()
+ {
+ $lastUsed = new \DateTime();
+ $token = new PersistentToken('fooclass', 'fooname', 'fooseries', 'footokenvalue', $lastUsed);
+
+ $this->assertEquals('fooclass', $token->getClass());
+ $this->assertEquals('fooname', $token->getUsername());
+ $this->assertEquals('fooseries', $token->getSeries());
+ $this->assertEquals('footokenvalue', $token->getTokenValue());
+ $this->assertSame($lastUsed, $token->getLastUsed());
+ }
+}