diff options
author | Bharat Mediratta <bharat@menalto.com> | 2010-01-02 15:49:17 -0800 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2010-01-02 15:49:17 -0800 |
commit | 11f6a3d1eb55193a8fd8ba14d0a34eacec87f51e (patch) | |
tree | 213833a3f2bffdddec617cf43e1108580c8a08ec /modules | |
parent | bad83900ae07490975541902f157d7e16a8254d9 (diff) | |
parent | ff95c4079e70cec101a214a07d2ef64ac381d5cd (diff) |
Merge branch 'master' of git@github.com:gallery/gallery3
Diffstat (limited to 'modules')
-rw-r--r-- | modules/gallery/tests/Gallery_Rest_Helper_Test.php | 9 | ||||
-rw-r--r-- | modules/tag/tests/Tag_Rest_Helper_Test.php | 28 |
2 files changed, 24 insertions, 13 deletions
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() { 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); |