From 31ecb009bac2d9177329aafb9596fbfa65bd6a04 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 17 Jan 2010 23:45:18 -0800 Subject: Get rid of urls_are_rawurlencoded_test -- it's no longer necessary since we can't have unsafe slugs. Add basic_validation_test. --- modules/gallery/tests/Item_Model_Test.php | 40 +++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 10 deletions(-) (limited to 'modules/gallery/tests/Item_Model_Test.php') diff --git a/modules/gallery/tests/Item_Model_Test.php b/modules/gallery/tests/Item_Model_Test.php index c4e150a6..ea6c2af6 100644 --- a/modules/gallery/tests/Item_Model_Test.php +++ b/modules/gallery/tests/Item_Model_Test.php @@ -163,16 +163,6 @@ class Item_Model_Test extends Unit_Test_Case { $this->assert_same("NEW_VALUE", $item->title); } - public function urls_are_rawurlencoded_test() { - $item = test::random_photo_unsaved(); - $item->slug = "foo bar"; - $item->name = "foo bar.jpg"; - $item->save(); - - $this->assert_equal("foo%20bar", $item->relative_url()); - $this->assert_equal("foo%20bar.jpg", $item->relative_path()); - } - public function move_album_test() { $album2 = test::random_album(); $album = test::random_album($album2); @@ -255,4 +245,34 @@ class Item_Model_Test extends Unit_Test_Case { return; } } + + public function basic_validation_test() { + $item = ORM::factory("item"); + $item->album_cover_item_id = rand(); // invalid + $item->description = str_repeat("x", 70000); // invalid + $item->name = null; + $item->parent_id = rand(); + $item->slug = null; + $item->sort_column = "bogus"; + $item->sort_order = "bogus"; + $item->title = null; + $item->type = "bogus"; + try { + $item->save(); + } catch (ORM_Validation_Exception $e) { + $this->assert_same(array("description" => "length", + "name" => "required", + "slug" => "required", + "title" => "required", + "album_cover_item_id" => "invalid_item", + "parent_id" => "invalid", + "sort_column" => "invalid", + "sort_order" => "invalid", + "type" => "invalid"), + $e->validation->errors()); + return; + } + + $this->assert_false(true, "Shouldn't get here"); + } } -- cgit v1.2.3