Browse Source

Add tests for SessionStorage::redirectUrl()

ADmad 10 years ago
parent
commit
30efc383a7
1 changed files with 30 additions and 0 deletions
  1. 30 0
      tests/TestCase/Auth/Storage/SessionStorageTest.php

+ 30 - 0
tests/TestCase/Auth/Storage/SessionStorageTest.php

@@ -102,4 +102,34 @@ class SessionStorageTest extends TestCase
 
         $this->storage->delete();
     }
+
+    /**
+     * Test redirectUrl()
+     *
+     * @return void
+     */
+    public function redirectUrl()
+    {
+        $url = '/url';
+
+        $this->session->expects($this->once())
+            ->method('write')
+            ->with('Auth.redirectUrl', $url);
+
+        $this->storage->redirectUrl($url);
+
+        $this->session->expects($this->once())
+            ->method('read')
+            ->with('Auth.redirectUrl')
+            ->will($this->returnValue($url));
+
+        $result = $this->storage->redirectUrl();
+        $this->assertEquals($url, $result);
+
+        $this->session->expects($this->once())
+            ->method('delete')
+            ->with('Auth.redirectUrl');
+
+        $this->storage->redirectUrl(false);
+    }
 }