diff options
Diffstat (limited to 'tests/TestBaseApi.php')
-rw-r--r-- | tests/TestBaseApi.php | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/tests/TestBaseApi.php b/tests/TestBaseApi.php index 9759db5..23e1812 100644 --- a/tests/TestBaseApi.php +++ b/tests/TestBaseApi.php @@ -11,6 +11,8 @@ * @link http://sourceforge.net/projects/semanticscuttle */ +require_once 'HTTP/Request2.php'; + /** * Base unittest class for web API tests. * @@ -89,7 +91,8 @@ class TestBaseApi extends TestBase * the request object with authentication details, so that * the user is logged in. * - * Only usable for API requests, not "normal" HTTP page requests + * Useful for HTTP API methods only, cannot be used with + * "normal" HTML pages since they do not support HTTP auth. * * @param string $urlSuffix Suffix for the URL * @param mixed $auth If user authentication is needed (true/false) @@ -166,6 +169,25 @@ class TestBaseApi extends TestBase /** + * Verifies that the HTTP response has status code 200 and + * content-type application/json; charset=utf-8 + * + * @param HTTP_Request2_Response $res HTTP Response object + * + * @return void + */ + protected function assertResponseJson200(HTTP_Request2_Response $res) + { + $this->assertEquals(200, $res->getStatus()); + $this->assertEquals( + 'application/json; charset=utf-8', + $res->getHeader('content-type') + ); + } + + + + /** * Writes a special unittest configuration file. * The unittest config file is read when a GET request with unittestMode=1 * is sent, and the user allowed unittestmode in config.php. |