summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2010-01-30 23:36:41 -0800
committerBharat Mediratta <bharat@menalto.com>2010-01-30 23:36:41 -0800
commita79d20a36135d50f77a7f11046b1d7ee392d46c7 (patch)
treee64fd4d80ac85116c883f67524106191936404db
parentd29028c4ea9002ac036a89a4478fb4640c86fedb (diff)
Use Item_Model::as_restful_array() to simplify tests.
-rw-r--r--modules/gallery/helpers/item_rest.php13
-rw-r--r--modules/gallery/tests/Item_Rest_Helper_Test.php10
2 files changed, 6 insertions, 17 deletions
diff --git a/modules/gallery/helpers/item_rest.php b/modules/gallery/helpers/item_rest.php
index f5056bc1..c0fc422a 100644
--- a/modules/gallery/helpers/item_rest.php
+++ b/modules/gallery/helpers/item_rest.php
@@ -75,20 +75,9 @@ class item_rest_Core {
$members[] = rest::url("item", $child);
}
- // Convert item ids to rest URLs for consistency
- $entity = $item->as_array();
- if ($tmp = $item->parent()) {
- $entity["parent"] = rest::url("item", $tmp);
- }
- unset($entity["parent_id"]);
- if ($tmp = $item->album_cover()) {
- $entity["album_cover"] = rest::url("item", $tmp);
- }
- unset($entity["album_cover_id"]);
-
return array(
"url" => $request->url,
- "entity" => $entity,
+ "entity" => $item->as_restful_array(),
"members" => $members,
"relationships" => rest::relationships("item", $item));
}
diff --git a/modules/gallery/tests/Item_Rest_Helper_Test.php b/modules/gallery/tests/Item_Rest_Helper_Test.php
index d91e0f58..088b1cbd 100644
--- a/modules/gallery/tests/Item_Rest_Helper_Test.php
+++ b/modules/gallery/tests/Item_Rest_Helper_Test.php
@@ -36,7 +36,7 @@ class Item_Rest_Helper_Test extends Gallery_Unit_Test_Case {
$request->params = new stdClass();
$this->assert_equal_array(
array("url" => rest::url("item", $album1),
- "entity" => $album1->as_array(),
+ "entity" => $album1->as_restful_array(),
"members" => array(
rest::url("item", $photo1),
rest::url("item", $album2)),
@@ -50,7 +50,7 @@ class Item_Rest_Helper_Test extends Gallery_Unit_Test_Case {
$request->params->scope = "direct";
$this->assert_equal_array(
array("url" => rest::url("item", $album1),
- "entity" => $album1->as_array(),
+ "entity" => $album1->as_restful_array(),
"members" => array(
rest::url("item", $photo1),
rest::url("item", $album2)),
@@ -64,7 +64,7 @@ class Item_Rest_Helper_Test extends Gallery_Unit_Test_Case {
$request->params->scope = "all";
$this->assert_equal_array(
array("url" => rest::url("item", $album1),
- "entity" => $album1->as_array(),
+ "entity" => $album1->as_restful_array(),
"members" => array(
rest::url("item", $photo1),
rest::url("item", $album2),
@@ -88,7 +88,7 @@ class Item_Rest_Helper_Test extends Gallery_Unit_Test_Case {
$request->params->name = "foo";
$this->assert_equal_array(
array("url" => rest::url("item", $album1),
- "entity" => $album1->as_array(),
+ "entity" => $album1->as_restful_array(),
"members" => array(
rest::url("item", $photo2)),
"relationships" => array(
@@ -108,7 +108,7 @@ class Item_Rest_Helper_Test extends Gallery_Unit_Test_Case {
$request->params->type = "album";
$this->assert_equal_array(
array("url" => rest::url("item", $album1),
- "entity" => $album1->as_array(),
+ "entity" => $album1->as_restful_array(),
"members" => array(
rest::url("item", $album2)),
"relationships" => array(