From ecb9a19cfaf627af4fc316a2125cd10d7e233150 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Tue, 1 Nov 2016 15:49:14 +0100 Subject: mmultipaste->delete_id: Fix inverted return value Broken in d2fdfc77f7a9485548869414d4377cd6848fe339 Signed-off-by: Florian Pritz --- application/models/mmultipaste.php | 2 +- application/test/tests/test_api_v2.php | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/application/models/mmultipaste.php b/application/models/mmultipaste.php index fc0889377..52ea4dfb4 100644 --- a/application/models/mmultipaste.php +++ b/application/models/mmultipaste.php @@ -125,7 +125,7 @@ class Mmultipaste extends CI_Model { $f = new \service\storage($this->get_tarball_path($id)); $f->unlink(); - return $this->id_exists($id); + return !$this->id_exists($id); } public function get_owner($id) diff --git a/application/test/tests/test_api_v2.php b/application/test/tests/test_api_v2.php index 7335c3bdd..0e52de50b 100644 --- a/application/test/tests/test_api_v2.php +++ b/application/test/tests/test_api_v2.php @@ -494,4 +494,33 @@ class test_api_v2 extends \test\Test { ), ), $ret, "expected error response"); } + + public function test_delete_canDeleteMultipaste() + { + $apikey = $this->createUserAndApikey(); + $ret = $this->uploadFile($apikey, "data/tests/small-file"); + $id = $ret["data"]["ids"][0]; + $ret = $this->CallEndpoint("POST", "file/create_multipaste", array( + "apikey" => $apikey, + "ids[1]" => $id, + )); + $this->expectSuccess("create multipaste", $ret); + + $mid = $ret['data']['url_id']; + $ret = $this->CallEndpoint("POST", "file/delete", array( + "apikey" => $apikey, + "ids[1]" => $mid, + )); + $this->expectSuccess("delete uploaded file", $ret); + + $this->t->ok(empty($ret["data"]["errors"]), "no errors"); + $this->t->is_deeply(array( + $mid => array( + "id" => $mid + ) + ), $ret["data"]["deleted"], "deleted wanted ID"); + $this->t->is($ret["data"]["total_count"], 1, "total_count correct"); + $this->t->is($ret["data"]["deleted_count"], 1, "deleted_count correct"); + } + } -- cgit v1.2.3-24-g4f1b