diff options
author | Bharat Mediratta <bharat@menalto.com> | 2010-01-17 23:45:18 -0800 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2010-01-17 23:47:16 -0800 |
commit | 31ecb009bac2d9177329aafb9596fbfa65bd6a04 (patch) | |
tree | 873520e799967850517db4640f3e1643a9e90b1b /modules/gallery/tests | |
parent | 06541f0e2a5cb9ee78b6b1553dd522dcc33a1b3d (diff) |
Get rid of urls_are_rawurlencoded_test -- it's no longer necessary
since we can't have unsafe slugs.
Add basic_validation_test.
Diffstat (limited to 'modules/gallery/tests')
-rw-r--r-- | modules/gallery/tests/Item_Model_Test.php | 40 |
1 files changed, 30 insertions, 10 deletions
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"); + } } |