Browse Source

Add assertNoRedirect method.

euromark 11 years ago
parent
commit
4e409d6a9d
1 changed files with 20 additions and 0 deletions
  1. 20 0
      src/TestSuite/IntegrationTestCase.php

+ 20 - 0
src/TestSuite/IntegrationTestCase.php

@@ -437,6 +437,26 @@ abstract class IntegrationTestCase extends TestCase {
 	}
 
 /**
+ * Asserts that the Location header is not set.
+ *
+ * @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->assertEmpty($result['Location'], $message);
+	}
+
+/**
  * Asserts response headers
  *
  * @param string $header The header to check