summaryrefslogtreecommitdiff
path: root/modules/comment/tests
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2010-05-14 16:19:53 -0700
committerBharat Mediratta <bharat@menalto.com>2010-05-14 16:19:53 -0700
commitad0e7254eb6e6a763c9b4d0a7252dc5982a814be (patch)
treef79887f228374640ab2cc80f3c638fc3eb62e1b4 /modules/comment/tests
parent9affa8ebbd539396d71f19003b91af577a8a183e (diff)
Require a well-formed email address for all comments.
Diffstat (limited to 'modules/comment/tests')
-rw-r--r--modules/comment/tests/Comment_Event_Test.php1
-rw-r--r--modules/comment/tests/Comment_Model_Test.php31
2 files changed, 32 insertions, 0 deletions
diff --git a/modules/comment/tests/Comment_Event_Test.php b/modules/comment/tests/Comment_Event_Test.php
index 62ffec2f..7cae9297 100644
--- a/modules/comment/tests/Comment_Event_Test.php
+++ b/modules/comment/tests/Comment_Event_Test.php
@@ -25,6 +25,7 @@ class Comment_Event_Test extends Gallery_Unit_Test_Case {
$comment->item_id = $album->id;
$comment->author_id = identity::guest()->id;
$comment->guest_name = "test";
+ $comment->guest_email = "test@test.com";
$comment->text = "text";
$comment->save();
diff --git a/modules/comment/tests/Comment_Model_Test.php b/modules/comment/tests/Comment_Model_Test.php
index f4e944f0..ee4d3d3c 100644
--- a/modules/comment/tests/Comment_Model_Test.php
+++ b/modules/comment/tests/Comment_Model_Test.php
@@ -22,6 +22,37 @@ class Comment_Model_Test extends Gallery_Unit_Test_Case {
identity::set_active_user(identity::admin_user());
}
+ public function guest_name_and_email_is_required_test() {
+ try {
+ $comment = ORM::factory("comment");
+ $comment->item_id = item::root()->id;
+ $comment->author_id = identity::guest()->id;
+ $comment->text = "text";
+ $comment->save();
+ } catch (ORM_Validation_Exception $e) {
+ $this->assert_equal(array("guest_name" => "required",
+ "guest_email" => "required"),
+ $e->validation->errors());
+ return;
+ }
+ }
+
+ public function guest_email_must_be_well_formed_test() {
+ try {
+ $comment = ORM::factory("comment");
+ $comment->item_id = item::root()->id;
+ $comment->author_id = identity::guest()->id;
+ $comment->guest_name = "guest";
+ $comment->guest_email = "bogus";
+ $comment->text = "text";
+ $comment->save();
+ } catch (ORM_Validation_Exception $e) {
+ $this->assert_equal(array("guest_email" => "invalid"),
+ $e->validation->errors());
+ return;
+ }
+ }
+
public function cant_view_comments_for_unviewable_items_test() {
$album = test::random_album();