Browse Source

fix session reset for IntegrationTestCase

Mark Scherer 11 years ago
parent
commit
cc858bb032
2 changed files with 17 additions and 18 deletions
  1. 7 18
      Controller/Component/CommonComponent.php
  2. 10 0
      TestSuite/IntegrationTestCase.php

+ 7 - 18
Controller/Component/CommonComponent.php

@@ -372,17 +372,6 @@ class CommonComponent extends Component {
 			'scope' => [],
 		];
 		return $this->manualLogin($id, $settings);
-		/*
-		if (!isset($this->User)) {
-			$this->User = ClassRegistry::init(defined('CLASS_USER') ? CLASS_USER : $this->userModel);
-		}
-		$data = $this->User->get($id);
-		if (!$data) {
-			return false;
-		}
-		$data = $data[$this->userModel];
-		return $this->Controller->Auth->login($data);
-		*/
 	}
 
 	/**
@@ -396,9 +385,9 @@ class CommonComponent extends Component {
 	 */
 	public function autoRedirect($whereTo, $allowSelf = true, $status = null) {
 		if ($allowSelf || $this->Controller->referer(null, true) !== '/' . $this->Controller->request->url) {
-			$this->Controller->redirect($this->Controller->referer($whereTo, true), $status);
+			return $this->Controller->redirect($this->Controller->referer($whereTo, true), $status);
 		}
-		$this->Controller->redirect($whereTo, $status);
+		return $this->Controller->redirect($whereTo, $status);
 	}
 
 	/**
@@ -413,7 +402,7 @@ class CommonComponent extends Component {
 	 * @return void
 	 */
 	public function postRedirect($whereTo, $status = 302) {
-		$this->Controller->redirect($whereTo, $status);
+		return $this->Controller->redirect($whereTo, $status);
 	}
 
 	/**
@@ -427,7 +416,7 @@ class CommonComponent extends Component {
 	public function autoPostRedirect($whereTo, $conditionalAutoRedirect = true, $status = 302) {
 		$referer = $this->Controller->referer($whereTo, true);
 		if (!$conditionalAutoRedirect && !empty($referer)) {
-			$this->postRedirect($referer, $status);
+			return $this->postRedirect($referer, $status);
 		}
 
 		if (!empty($referer)) {
@@ -456,10 +445,10 @@ class CommonComponent extends Component {
 				if (!in_array($referer['action'], $this->Controller->autoRedirectActions)) {
 					continue;
 				}
-				$this->autoRedirect($whereTo, true, $status);
+				return $this->autoRedirect($whereTo, true, $status);
 			}
 		}
-		$this->postRedirect($whereTo, $status);
+		return $this->postRedirect($whereTo, $status);
 	}
 
 	/**
@@ -499,7 +488,7 @@ class CommonComponent extends Component {
 	 */
 	public function prgRedirect($status = 302) {
 		if (!empty($_COOKIE[Configure::read('Session.cookie')])) {
-			$this->Controller->redirect('/' . $this->Controller->request->url, $status);
+			return $this->Controller->redirect('/' . $this->Controller->request->url, $status);
 		}
 	}
 

+ 10 - 0
TestSuite/IntegrationTestCase.php

@@ -188,6 +188,16 @@ abstract class IntegrationTestCase extends MyControllerTestCase {
 		return $result;
 	}
 
+	public function tearDown() {
+		parent::tearDown();
+
+		if ((float)Configure::version() >= 2.7) {
+			CakeSession::clear(false);
+		} else {
+			$_SESSION = null;
+		}
+	}
+
 	/**
 	 * Fetch a view variable by name.
 	 *