Skip to content

Commit

Permalink
Use Item_Model::as_restful_array() to simplify tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
bharat committed Jan 31, 2010
1 parent d29028c commit a79d20a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
13 changes: 1 addition & 12 deletions modules/gallery/helpers/item_rest.php
Expand Up @@ -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));
}
Expand Down
10 changes: 5 additions & 5 deletions modules/gallery/tests/Item_Rest_Helper_Test.php
Expand Up @@ -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)),
Expand All @@ -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)),
Expand All @@ -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),
Expand All @@ -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(
Expand All @@ -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(
Expand Down

0 comments on commit a79d20a

Please sign in to comment.