浏览代码

Add responseEquals

Mark Scherer 11 年之前
父节点
当前提交
43184ee030
共有 1 个文件被更改,包括 15 次插入1 次删除
  1. 15 1
      TestSuite/IntegrationTestCase.php

+ 15 - 1
TestSuite/IntegrationTestCase.php

@@ -344,11 +344,25 @@ abstract class IntegrationTestCase extends MyControllerTestCase {
  * @param string $message The failure message that will be appended to the generated message.
  * @param string $message The failure message that will be appended to the generated message.
  * @return void
  * @return void
  */
  */
+	public function assertResponseEquals($content, $message = '') {
+		if (!$this->_response) {
+			$this->fail('No response set, cannot assert content. ' . $message);
+		}
+		$this->assertSame($content, (string)$this->_response->body(), $message);
+	}
+
+/**
+ * Assert content exists in the response body.
+ *
+ * @param string $content The content to check for.
+ * @param string $message The failure message that will be appended to the generated message.
+ * @return void
+ */
 	public function assertResponseContains($content, $message = '') {
 	public function assertResponseContains($content, $message = '') {
 		if (!$this->_response) {
 		if (!$this->_response) {
 			$this->fail('No response set, cannot assert content. ' . $message);
 			$this->fail('No response set, cannot assert content. ' . $message);
 		}
 		}
-		$this->assertContains($content, $this->_response->body(), $message);
+		$this->assertContains($content, (string)$this->_response->body(), $message);
 	}
 	}
 
 
 /**
 /**