From d4ad81e657e08630cca80c69b05d7d5fcc6c83d8 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sat, 2 Jan 2010 15:04:43 -0800 Subject: Correct unexpected error in gallery_rest_put_album_no_path_test --- modules/gallery/tests/Gallery_Rest_Helper_Test.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/gallery/tests/Gallery_Rest_Helper_Test.php b/modules/gallery/tests/Gallery_Rest_Helper_Test.php index 605a4f37..65a60ff1 100644 --- a/modules/gallery/tests/Gallery_Rest_Helper_Test.php +++ b/modules/gallery/tests/Gallery_Rest_Helper_Test.php @@ -132,8 +132,13 @@ class Gallery_Rest_Helper_Test extends Unit_Test_Case { "title" => "Updated Title", "name" => "new name"); - $this->assert_equal(json_encode(array("status" => "ERROR", "message" => "Invalid request")), - gallery_rest::put($request)); + try { + gallery_rest::put($request); + } catch (Rest_Exception $e) { + $this->assert_equal("400 Bad request", $e->getMessage()); + } catch (Exception $e) { + $this->assert_false(true, $e->__toString()); + } } public function gallery_rest_put_album_not_found_test() { -- cgit v1.2.3 From ff95c4079e70cec101a214a07d2ef64ac381d5cd Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sat, 2 Jan 2010 15:48:54 -0800 Subject: Fix the tag_rest helper tests --- modules/tag/tests/Tag_Rest_Helper_Test.php | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'modules') diff --git a/modules/tag/tests/Tag_Rest_Helper_Test.php b/modules/tag/tests/Tag_Rest_Helper_Test.php index 055e5cec..4e8dd527 100644 --- a/modules/tag/tests/Tag_Rest_Helper_Test.php +++ b/modules/tag/tests/Tag_Rest_Helper_Test.php @@ -19,6 +19,10 @@ */ class Tag_Rest_Helper_Test extends Unit_Test_Case { public function setup() { + try { + Database::instance()->query("TRUNCATE {tags}"); + Database::instance()->query("TRUNCATE {items_tags}"); + } catch (Exception $e) { } $this->_save = array($_GET, $_POST, $_SERVER, $_FILES); $this->_saved_active_user = identity::active_user(); } @@ -28,9 +32,6 @@ class Tag_Rest_Helper_Test extends Unit_Test_Case { identity::set_active_user($this->_saved_active_user); try { - Database::instance()->query("TRUNCATE {tags}"); - Database::instance()->query("TRUNCATE {items_tags}"); - if (!empty($this->_user)) { $this->_user->delete(); } @@ -50,7 +51,7 @@ class Tag_Rest_Helper_Test extends Unit_Test_Case { } private function _create_album($tags=array(), $parent=null) { - $album_name = "album_" . rand(); + $album_name = "tag_album_" . rand(); if (empty($parent)) { $parent = ORM::factory("item", 1); } @@ -63,7 +64,7 @@ class Tag_Rest_Helper_Test extends Unit_Test_Case { private function _create_image($tags=array(), $parent=null) { $filename = MODPATH . "gallery/tests/test.jpg"; - $image_name = "image_" . rand(); + $image_name = "tag_image_" . rand(); if (empty($parent)) { $parent = ORM::factory("item", 1); } @@ -105,6 +106,9 @@ class Tag_Rest_Helper_Test extends Unit_Test_Case { $child = $this->_create_album(array("albums", "A1", "T1"), $album); $photo = $this->_create_image(array("photos", "P1", "T1"), $child); $sibling = $this->_create_image(array("photos", "P3"), $album); + $child->reload(); + $album->reload(); + $request = (object)array("arguments" => array("albums")); $resources = array(); @@ -113,9 +117,8 @@ class Tag_Rest_Helper_Test extends Unit_Test_Case { "has_children" => $resource->children_count() > 0, "path" => $resource->relative_url(), "thumb_url" => $resource->thumb_url(), - "thumb_dimensions" => array( - "width" => $resource->thumb_width, - "height" => $resource->thumb_height), + "thumb_dimensions" => array("width" => $resource->thumb_width, + "height" => $resource->thumb_height), "has_thumb" => $resource->has_thumb(), "title" => $resource->title); @@ -229,7 +232,11 @@ class Tag_Rest_Helper_Test extends Unit_Test_Case { $album = $this->_create_album(array("albums", "A1", "T1")); $child = $this->_create_album(array("albums", "A1", "T1"), $album); $photo = $this->_create_image(array("photos", "P1", "T1"), $child); + $child->reload(); $sibling = $this->_create_image(array("photos", "P3"), $album); + $child->reload(); + $album->reload(); + $request = (object)array("arguments" => array("albums"), "new_name" => "new name"); $this->assert_equal(json_encode(array("status" => "OK")), tag_rest::put($request)); @@ -241,9 +248,8 @@ class Tag_Rest_Helper_Test extends Unit_Test_Case { "has_children" => $resource->children_count() > 0, "path" => $resource->relative_url(), "thumb_url" => $resource->thumb_url(), - "thumb_dimensions" => array( - "width" => $resource->thumb_width, - "height" => $resource->thumb_height), + "thumb_dimensions" => array("width" => $resource->thumb_width, + "height" => $resource->thumb_height), "has_thumb" => $resource->has_thumb(), "title" => $resource->title); -- cgit v1.2.3