summaryrefslogtreecommitdiff
path: root/modules/gallery/tests
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2013-03-12 17:00:55 -0700
committerBharat Mediratta <bharat@menalto.com>2013-03-12 17:00:55 -0700
commite2ee3499ca1d7980dd84c7c649d69ce11f381915 (patch)
tree8df518a597c5967755816c9f6b8e4f08381f6e03 /modules/gallery/tests
parent94ac5521521309d81cafeb44b3ed5d8ff3527cc8 (diff)
parented20798b99c0c6ab90e4d141ff74d7c2ca606ae7 (diff)
Merge pull request #209 from shadlaws/fix_2057
#2057 - Revise item name and slug validation - backslashes, refactor, error messages.
Diffstat (limited to 'modules/gallery/tests')
-rw-r--r--modules/gallery/tests/Item_Model_Test.php45
1 files changed, 44 insertions, 1 deletions
diff --git a/modules/gallery/tests/Item_Model_Test.php b/modules/gallery/tests/Item_Model_Test.php
index 83c9f79d..e3a4a6b7 100644
--- a/modules/gallery/tests/Item_Model_Test.php
+++ b/modules/gallery/tests/Item_Model_Test.php
@@ -124,13 +124,56 @@ class Item_Model_Test extends Gallery_Unit_Test_Case {
$this->assert_equal($fullsize_file, file_get_contents($photo->file_path()));
}
- public function item_rename_wont_accept_slash_test() {
+ public function photo_rename_wont_accept_slash_test() {
$item = test::random_photo();
$item->name = "/no_slashes/allowed/";
$item->save();
$this->assert_equal("no_slashes_allowed.jpg", $item->name);
}
+ public function photo_rename_wont_accept_backslash_test() {
+ $item = test::random_photo();
+ $item->name = "\\no_backslashes\\allowed\\";
+ $item->save();
+ $this->assert_equal("no_backslashes_allowed.jpg", $item->name);
+ }
+
+ public function album_rename_wont_accept_slash_test() {
+ try {
+ $item = test::random_album();
+ $item->name = "/no_album_slashes/allowed/";
+ $item->save();
+ } catch (ORM_Validation_Exception $e) {
+ $this->assert_same(array("name" => "no_slashes"), $e->validation->errors());
+ return; // pass
+ }
+ $this->assert_true(false, "Shouldn't get here");
+ }
+
+ public function album_rename_wont_accept_backslash_test() {
+ try {
+ $item = test::random_album();
+ $item->name = "\\no_album_backslashes\\allowed\\";
+ $item->save();
+ } catch (ORM_Validation_Exception $e) {
+ $this->assert_same(array("name" => "no_backslashes"), $e->validation->errors());
+ return; // pass
+ }
+ $this->assert_true(false, "Shouldn't get here");
+ }
+
+ public function album_rename_wont_accept_trailing_period_test() {
+ try {
+ $item = test::random_album();
+ $item->name = ".no_trailing_period.allowed.";
+ $item->save();
+ } catch (ORM_Validation_Exception $e) {
+ $this->assert_same(array("name" => "no_trailing_period"), $e->validation->errors());
+ return; // pass
+ }
+ $this->assert_true(false, "Shouldn't get here");
+ }
+
public function move_album_test() {
$album2 = test::random_album();
$album1 = test::random_album($album2);