diff options
author | Florian Pritz <bluewind@xinu.at> | 2017-07-04 11:59:23 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2017-07-04 12:10:49 +0200 |
commit | 5a94df2221664f88fd3c8fc07e068fc2ce52118d (patch) | |
tree | 30958cf6e2a6f379aaefeee9b3413120e2679a4b /application | |
parent | 56f176309428541e6868cb9c4a89f51f5cbdd2f8 (diff) |
API: Fix return type of empty values in file/delete
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application')
-rw-r--r-- | application/controllers/api/v2/file.php | 6 | ||||
-rw-r--r-- | application/test/tests/api_v2/test_file_delete.php | 15 |
2 files changed, 20 insertions, 1 deletions
diff --git a/application/controllers/api/v2/file.php b/application/controllers/api/v2/file.php index c3a42388b..15a43fc45 100644 --- a/application/controllers/api/v2/file.php +++ b/application/controllers/api/v2/file.php @@ -75,7 +75,11 @@ class file extends \controllers\api\api_controller { { $this->muser->require_access("apikey"); $ids = $this->input->post_array("ids"); - return \service\files::delete($ids); + $ret = \service\files::delete($ids); + + $ret = ensure_json_keys_contain_objects($ret, array("errors", "deleted")); + + return $ret; } public function create_multipaste() diff --git a/application/test/tests/api_v2/test_file_delete.php b/application/test/tests/api_v2/test_file_delete.php index b4d63409d..d9ffc5b2c 100644 --- a/application/test/tests/api_v2/test_file_delete.php +++ b/application/test/tests/api_v2/test_file_delete.php @@ -64,4 +64,19 @@ class test_file_delete extends common { $this->t->is($ret["data"]["deleted_count"], 0, "deleted_count correct"); } + public function test_delete_empty_json_structure() + { + $apikey = $this->createUserAndApikey(); + $ret = $this->uploadFile($apikey, "data/tests/small-file"); + $id = $ret["data"]["ids"][0]; + + $ret = $this->CallEndpoint("POST", "file/delete", array( + "apikey" => $apikey, + "ids[1]" => $id, + ), true); + + $this->t->is($ret, '{"status":"success","data":{"errors":{},"deleted":{"'.$id.'":{"id":"'.$id.'"}},"total_count":1,"deleted_count":1}}', "empty lists should be json objects, not arrays"); + } + + } |