summaryrefslogtreecommitdiffstats
path: root/application/test/tests/api_v2/test_history.php
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2017-07-04 11:31:38 +0200
committerFlorian Pritz <bluewind@xinu.at>2017-07-04 12:10:44 +0200
commit9bdf0973b337cbf73287422cc5fdceabc8703e61 (patch)
treefb02b08b50a33e39229e4d0cfddec15b36852942 /application/test/tests/api_v2/test_history.php
parent0ce11c1416c0bce491952410e791f7ca6cfad2dd (diff)
API: Fix return type of empty values in file/history
If the array is not casted to a object, json_encode will encode it as [] if empty, but {} if it contains data. Always return an object by casting the array to an object if it is empty. Fixes #15 Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application/test/tests/api_v2/test_history.php')
-rw-r--r--application/test/tests/api_v2/test_history.php10
1 files changed, 10 insertions, 0 deletions
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();