Browse Source

Add test for Auth.redirect session var clearing.

ADmad 13 years ago
parent
commit
7becd58237
1 changed files with 21 additions and 0 deletions
  1. 21 0
      lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php

+ 21 - 0
lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php

@@ -319,6 +319,7 @@ class AuthComponentTest extends CakeTestCase {
 		$this->Auth = new TestAuthComponent($collection);
 		$this->Auth->request = $request;
 		$this->Auth->response = $this->getMock('CakeResponse');
+		AuthComponent::$sessionKey = 'Auth.User';
 
 		$this->Controller->Components->init($this->Controller);
 
@@ -442,6 +443,26 @@ class AuthComponentTest extends CakeTestCase {
 	}
 
 /**
+ * testRedirectVarClearing method
+ *
+ * @return void
+ */
+	public function testRedirectVarClearing() {
+		$this->Controller->request['controller'] = 'auth_test';
+		$this->Controller->request['action'] = 'admin_add';
+		$this->Controller->here = '/auth_test/admin_add';
+		$this->assertNull($this->Auth->Session->read('Auth.redirect'));
+
+		$this->Auth->authenticate = array('Form');
+		$this->Auth->startup($this->Controller);
+		$this->assertEquals('/auth_test/admin_add', $this->Auth->Session->read('Auth.redirect'));
+
+		$this->Auth->Session->write('Auth.User', array('username' => 'admad'));
+		$this->Auth->startup($this->Controller);
+		$this->assertNull($this->Auth->Session->read('Auth.redirect'));
+	}
+
+/**
  * testAuthorizeFalse method
  *
  * @return void