]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Improve SessionManager tests 1005/head
authorVirtualTam <virtualtam@flibidi.net>
Tue, 24 Oct 2017 20:01:02 +0000 (22:01 +0200)
committerVirtualTam <virtualtam@flibidi.net>
Tue, 24 Oct 2017 20:01:02 +0000 (22:01 +0200)
Signed-off-by: VirtualTam <virtualtam@flibidi.net>
tests/SessionManagerTest.php

index 9fa60dc5f6a973293414d034a462c102ccfcbb99..a92c3cccc131c309882c2bda689a3baa507aa148 100644 (file)
@@ -50,6 +50,29 @@ class SessionManagerTest extends TestCase
         $this->assertEquals(40, strlen($token));
     }
 
+    /**
+     * Check a session token
+     */
+    public function testCheckToken()
+    {
+        $token = '4dccc3a45ad9d03e5542b90c37d8db6d10f2b38b';
+        $session = [
+            'tokens' => [
+                $token => 1,
+            ],
+        ];
+        $conf = new FakeConfigManager();
+        $sessionManager = new SessionManager($session, $conf);
+
+
+        // check and destroy the token
+        $this->assertTrue($sessionManager->checkToken($token));
+        $this->assertFalse(isset($session['tokens'][$token]));
+
+        // ensure the token has been destroyed
+        $this->assertFalse($sessionManager->checkToken($token));
+    }
+
     /**
      * Generate and check a session token
      */