Permalink
Browse files

Use Item_Model::as_restful_array() to simplify tests.

  • Loading branch information...
1 parent d29028c commit a79d20a36135d50f77a7f11046b1d7ee392d46c7 @bharat bharat committed Jan 31, 2010
Showing with 6 additions and 17 deletions.
  1. +1 −12 modules/gallery/helpers/item_rest.php
  2. +5 −5 modules/gallery/tests/Item_Rest_Helper_Test.php
View
13 modules/gallery/helpers/item_rest.php
@@ -75,20 +75,9 @@ static function get($request) {
$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));
}
View
10 modules/gallery/tests/Item_Rest_Helper_Test.php
@@ -36,7 +36,7 @@ public function get_scope_test() {
$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 @@ public function get_scope_test() {
$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 @@ public function get_scope_test() {
$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 @@ public function get_children_like_test() {
$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 @@ public function get_children_type_test() {
$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(

0 comments on commit a79d20a

Please sign in to comment.