ソースを参照

assertNoRedirect

euromark 11 年 前
コミット
1fe7817968
1 ファイル変更22 行追加0 行削除
  1. 22 0
      TestSuite/IntegrationTestCase.php

+ 22 - 0
TestSuite/IntegrationTestCase.php

@@ -278,6 +278,28 @@ abstract class IntegrationTestCase extends MyControllerTestCase {
 	}
 
 /**
+ * Asserts that the Location header is correct.
+ *
+ * @param string|array $url The url you expected the client to go to. This
+ *   can either be a string URL or an array compatible with Router::url()
+ * @param string $message The failure message that will be appended to the generated message.
+ * @return void
+ */
+	public function assertNoRedirect($message = '') {
+		if (!$this->_response) {
+			$this->fail('No response set, cannot assert location header. ' . $message);
+		}
+		$result = $this->_response->header();
+		if (!$message) {
+			$message = 'Redirect header set';
+		}
+		if (!empty($result['Location'])) {
+			$message .= ': ' . $result['Location'];
+		}
+		$this->assertTrue(empty($result['Location']), $message);
+	}
+
+/**
  * Assert response headers
  *
  * @param string $header The header to check