diff options
Diffstat (limited to 'application/test')
-rw-r--r-- | application/test/Test.php | 6 | ||||
-rw-r--r-- | application/test/tests/api_v2/common.php | 4 | ||||
-rw-r--r-- | application/test/tests/api_v2/test_history.php | 10 |
3 files changed, 17 insertions, 3 deletions
diff --git a/application/test/Test.php b/application/test/Test.php index 33278436b..b8052fbba 100644 --- a/application/test/Test.php +++ b/application/test/Test.php @@ -90,10 +90,14 @@ abstract class Test { // Method: POST, PUT, GET etc // Data: array("param" => "value") ==> index.php?param=value // Source: http://stackoverflow.com/a/9802854/953022 - protected function CallAPI($method, $url, $data = false) + protected function CallAPI($method, $url, $data = false, $return_json = false) { $result = $this->SendHTTPRequest($method, $url, $data); + if ($return_json) { + return $result; + } + $json = json_decode($result, true); if ($json === NULL) { $this->t->fail("json decode"); diff --git a/application/test/tests/api_v2/common.php b/application/test/tests/api_v2/common.php index dbef3cc9c..103e156a8 100644 --- a/application/test/tests/api_v2/common.php +++ b/application/test/tests/api_v2/common.php @@ -53,8 +53,8 @@ class common extends \test\Test { return $this->createApikey($userid, $access_level); } - protected function callEndpoint($verb, $endpoint, $data) + protected function callEndpoint($verb, $endpoint, $data, $return_json = false) { - return $this->CallAPI($verb, "$this->server_url/api/v2.0.0/$endpoint", $data); + return $this->CallAPI($verb, "$this->server_url/api/v2.0.0/$endpoint", $data, $return_json); } } diff --git a/application/test/tests/api_v2/test_history.php b/application/test/tests/api_v2/test_history.php index 3a168cafa..f09aab9bb 100644 --- a/application/test/tests/api_v2/test_history.php +++ b/application/test/tests/api_v2/test_history.php @@ -31,6 +31,16 @@ class test_history extends common { $this->t->is($ret["data"]["total_size"], "0", "total_size = 0 since no uploads"); } + public function test_history_empty_json_structure() + { + $apikey = $this->createUserAndApikey(); + $ret = $this->CallEndpoint("POST", "file/history", array( + "apikey" => $apikey, + ), true); + + $this->t->is($ret, '{"status":"success","data":{"items":{},"multipaste_items":{},"total_size":"0"}}', "empty lists should be json objects, not arrays"); + } + public function test_history_notEmptyAfterUploadSameMD5() { $apikey = $this->createUserAndApikey(); |