Browse Source

Add assertResponseSuccess() to also cover 3xx.

Mark Scherer 11 years ago
parent
commit
10e23f44f8

+ 10 - 0
src/TestSuite/IntegrationTestCase.php

@@ -389,6 +389,16 @@ abstract class IntegrationTestCase extends TestCase
     }
 
     /**
+     * Asserts that the response status code is in the 2xx/3xx range.
+     *
+     * @return void
+     */
+    public function assertResponseSuccess()
+    {
+        $this->_assertStatus(200, 308, 'Status code is not between 200 and 308');
+    }
+
+    /**
      * Asserts that the response status code is in the 4xx range.
      *
      * @return void

+ 6 - 0
tests/TestCase/TestSuite/IntegrationTestCaseTest.php

@@ -153,6 +153,12 @@ class IntegrationTestCaseTest extends IntegrationTestCase
         $this->_response->statusCode(204);
         $this->assertResponseOk();
 
+        $this->_response->statusCode(202);
+        $this->assertResponseSuccess();
+
+        $this->_response->statusCode(302);
+        $this->assertResponseSuccess();
+
         $this->_response->statusCode(400);
         $this->assertResponseError();