summaryrefslogtreecommitdiff
path: root/modules/tag
diff options
context:
space:
mode:
Diffstat (limited to 'modules/tag')
-rw-r--r--modules/tag/helpers/tag_rest.php14
-rw-r--r--modules/tag/tests/Tag_Rest_Helper_Test.php12
2 files changed, 15 insertions, 11 deletions
diff --git a/modules/tag/helpers/tag_rest.php b/modules/tag/helpers/tag_rest.php
index cd1ca6c6..0c06587b 100644
--- a/modules/tag/helpers/tag_rest.php
+++ b/modules/tag/helpers/tag_rest.php
@@ -55,12 +55,12 @@ class tag_rest_Core {
}
}
- return rest::success($resources);
+ return rest::reply($resources);
}
static function post($request) {
if (empty($request->arguments) || count($request->arguments) != 1 || empty($request->path)) {
- throw new Rest_Exception(400, "Bad request");
+ throw new Rest_Exception("Bad request", 400);
}
$path = $request->path;
$tags = explode(",", $request->arguments[0]);
@@ -80,12 +80,12 @@ class tag_rest_Core {
foreach ($tags as $tag) {
tag::add($item, $tag);
}
- return rest::success();
+ return rest::reply();
}
static function put($request) {
if (empty($request->arguments[0]) || empty($request->new_name)) {
- throw new Rest_Exception(400, "Bad request");
+ throw new Rest_Exception("Bad request", 400);
}
$name = $request->arguments[0];
@@ -100,12 +100,12 @@ class tag_rest_Core {
$tag->name = $request->new_name;
$tag->save();
- return rest::success();
+ return rest::reply();
}
static function delete($request) {
if (empty($request->arguments[0])) {
- throw new Rest_Exception(400, "Bad request");
+ throw new Rest_Exception("Bad request", 400);
}
$tags = explode(",", $request->arguments[0]);
if (!empty($request->path)) {
@@ -127,7 +127,7 @@ class tag_rest_Core {
};
tag::compact();
- return rest::success();
+ return rest::reply();
}
private static function _get_items($request) {
diff --git a/modules/tag/tests/Tag_Rest_Helper_Test.php b/modules/tag/tests/Tag_Rest_Helper_Test.php
index 4e8dd527..185953ab 100644
--- a/modules/tag/tests/Tag_Rest_Helper_Test.php
+++ b/modules/tag/tests/Tag_Rest_Helper_Test.php
@@ -133,7 +133,8 @@ class Tag_Rest_Helper_Test extends Unit_Test_Case {
try {
tag_rest::post($request);
} catch (Rest_Exception $e) {
- $this->assert_equal("400 Bad request", $e->getMessage());
+ $this->assert_equal(400, $e->getCode());
+ $this->assert_equal("Bad request", $e->getMessage());
} catch (Exception $e) {
$this->assert_false(true, $e->__toString());
}
@@ -191,7 +192,8 @@ class Tag_Rest_Helper_Test extends Unit_Test_Case {
try {
tag_rest::put($request);
} catch (Rest_Exception $e) {
- $this->assert_equal("400 Bad request", $e->getMessage());
+ $this->assert_equal(400, $e->getCode());
+ $this->assert_equal("Bad request", $e->getMessage());
} catch (Exception $e) {
$this->assert_false(true, $e->__toString());
}
@@ -202,7 +204,8 @@ class Tag_Rest_Helper_Test extends Unit_Test_Case {
try {
tag_rest::put($request);
} catch (Rest_Exception $e) {
- $this->assert_equal("400 Bad request", $e->getMessage());
+ $this->assert_equal(400, $e->getCode());
+ $this->assert_equal("Bad request", $e->getMessage());
} catch (Exception $e) {
$this->assert_false(true, $e->__toString());
}
@@ -211,7 +214,8 @@ class Tag_Rest_Helper_Test extends Unit_Test_Case {
try {
tag_rest::put($request);
} catch (Rest_Exception $e) {
- $this->assert_equal("400 Bad request", $e->getMessage());
+ $this->assert_equal(400, $e->getCode());
+ $this->assert_equal("Bad request", $e->getMessage());
} catch (Exception $e) {
$this->assert_false(true, $e->__toString());
}