From ca909a49ae16dc1d5a0d8448f84c32c7900ba06e Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Fri, 22 Jan 2010 01:09:38 -0800 Subject: New tests for tag_item_rest --- modules/tag/tests/Tag_Item_Rest_Helper_Test.php | 68 +++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 modules/tag/tests/Tag_Item_Rest_Helper_Test.php (limited to 'modules/tag/tests') diff --git a/modules/tag/tests/Tag_Item_Rest_Helper_Test.php b/modules/tag/tests/Tag_Item_Rest_Helper_Test.php new file mode 100644 index 00000000..6c49ad67 --- /dev/null +++ b/modules/tag/tests/Tag_Item_Rest_Helper_Test.php @@ -0,0 +1,68 @@ +query("TRUNCATE {tags}"); + Database::instance()->query("TRUNCATE {items_tags}"); + } catch (Exception $e) { } + } + + public function get_test() { + $tag = tag::add(item::root(), "tag1")->reload(); + + $request->url = rest::url("tag_item", $tag, item::root()); + $this->assert_equal_array( + array("url" => rest::url("tag_item", $tag, item::root()), + "members" => array( + rest::url("tag", $tag), + rest::url("item", item::root()))), + tag_item_rest::get($request)); + } + + public function get_with_invalid_url_test() { + $request->url = "bogus"; + try { + tag_item_rest::get($request); + } catch (Kohana_404_Exception $e) { + return; // pass + } + $this->assert_true(false, "Shouldn't get here"); + } + + public function delete_test() { + $tag = tag::add(item::root(), "tag1")->reload(); + + $request->url = rest::url("tag_item", $tag, item::root()); + tag_item_rest::delete($request); + + $this->assert_false($tag->reload()->has(item::root())); + } + + public function resolve_test() { + $album = test::random_album(); + $tag = tag::add($album, "tag1")->reload(); + + + $tuple = rest::resolve(rest::url("tag_item", $tag, $album)); + $this->assert_equal_array($tag->as_array(), $tuple[0]->as_array()); + $this->assert_equal_array($album->as_array(), $tuple[1]->as_array()); + } +} -- cgit v1.2.3