Browse Source

Correct IntegrationTestCase regarding redirects.

Mark Scherer 11 years ago
parent
commit
8584acaa16
1 changed files with 10 additions and 0 deletions
  1. 10 0
      TestSuite/IntegrationTestCase.php

+ 10 - 0
TestSuite/IntegrationTestCase.php

@@ -3,6 +3,7 @@ App::uses('MyControllerTestCase', 'Tools.TestSuite');
 App::uses('Router', 'Routing');
 App::uses('Dispatcher', 'Routing');
 App::uses('EventManager', 'Event');
+App::uses('CakeSession', 'Model/Datasource');
 
 /**
  * A test case class intended to make integration tests of
@@ -185,12 +186,21 @@ abstract class IntegrationTestCase extends MyControllerTestCase {
 		$this->_request = $this->controller->request;
 		$this->_requestSession = $this->controller->Session;
 
+		// Shim result of https://github.com/cakephp/cakephp/pull/5744 for earlier versions
+		if ((float)Configure::version() <= 2.6) {
+			$header = $this->_response->header();
+			if (isset($header['Location']) && $this->_response->statusCode() === 200) {
+				$this->_response->statusCode(302);
+			}
+		}
+
 		return $result;
 	}
 
 	public function tearDown() {
 		parent::tearDown();
 
+		// Workaround for https://github.com/cakephp/cakephp/pull/5558 for earlier versions
 		if ((float)Configure::version() >= 2.7) {
 			CakeSession::clear(false);
 		} else {