diff options
author | Tim Almdal <tnalmdal@shaw.ca> | 2008-12-29 21:09:44 +0000 |
---|---|---|
committer | Tim Almdal <tnalmdal@shaw.ca> | 2008-12-29 21:09:44 +0000 |
commit | 69603ede7a0d7567f37025eee713975282122d13 (patch) | |
tree | 1d270e63199faac57a7f2cbd939da04eb64576e6 /modules/comment/tests | |
parent | 2bfddc4c87443640098387630967f6d141a9fce6 (diff) |
Implemented bharat's suggestions to the comment module in preparation for the spam_filter module
Diffstat (limited to 'modules/comment/tests')
-rw-r--r-- | modules/comment/tests/Comment_Helper_Test.php | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/modules/comment/tests/Comment_Helper_Test.php b/modules/comment/tests/Comment_Helper_Test.php index 81ec12a8..10903843 100644 --- a/modules/comment/tests/Comment_Helper_Test.php +++ b/modules/comment/tests/Comment_Helper_Test.php @@ -18,8 +18,25 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class Comment_Helper_Test extends Unit_Test_Case { + private $_ip_address; + private $_user_agent; + + public function setup() { + $this->_ip_address = Input::instance()->ip_address; + $this->_user_agent = Kohana::$user_agent; + } + + public function teardown() { + Input::instance()->ip_address = $this->_ip_address; + Kohana::$user_agent = $this->_user_agent; + } + public function create_comment_test() { $rand = rand(); + + Input::instance()->ip_address = "1.1.1.1"; + Kohana::$user_agent = "Gallery3 Unit Test"; + $comment = comment::create($rand, $rand, $rand, $rand, $rand, $rand); $this->assert_equal($rand, $comment->author); @@ -27,11 +44,15 @@ class Comment_Helper_Test extends Unit_Test_Case { $this->assert_equal($rand, $comment->text); $this->assert_equal($rand, $comment->item_id); $this->assert_equal($rand, $comment->url); + $this->assert_equal("1.1.1.1", $comment->ip_addr); + $this->assert_equal("Gallery3 Unit Test", $comment->user_agent); $this->assert_true(!empty($comment->created)); } public function update_comment_test() { $rand = rand(); + Input::instance()->ip_address = "1.1.1.1"; + Kohana::$user_agent = "Gallery3 Unit Test"; $comment = comment::create($rand, $rand, $rand, $rand, $rand, $rand); $this->assert_equal($rand, $comment->author); @@ -39,19 +60,27 @@ class Comment_Helper_Test extends Unit_Test_Case { $this->assert_equal($rand, $comment->text); $this->assert_equal($rand, $comment->item_id); $this->assert_equal($rand, $comment->url); + $this->assert_equal("1.1.1.1", $comment->ip_addr); + $this->assert_equal("Gallery3 Unit Test", $comment->user_agent); $this->assert_true(!empty($comment->created)); $rand2 = rand(); + Input::instance()->ip_address = "1.1.1.2"; + Kohana::$user_agent = "Gallery3 Unit Test New Agent"; comment::update($comment, $rand2, $rand2, $rand2, $rand2, $rand2); $this->assert_equal($rand2, $comment->author); $this->assert_equal($rand2, $comment->email); $this->assert_equal($rand2, $comment->text); $this->assert_equal($rand, $comment->item_id); + $this->assert_equal("1.1.1.2", $comment->ip_addr); $this->assert_equal($rand2, $comment->url); + $this->assert_equal("Gallery3 Unit Test New Agent", $comment->user_agent); } public function update_comment_no_change_test() { $rand = rand(); + Input::instance()->ip_address = "1.1.1.1"; + Kohana::$user_agent = "Gallery3 Unit Test"; $comment = comment::create($rand, $rand, $rand, $rand, $rand, $rand); $this->assert_equal($rand, $comment->author); @@ -60,6 +89,8 @@ class Comment_Helper_Test extends Unit_Test_Case { $this->assert_equal($rand, $comment->item_id); $this->assert_equal($rand, $comment->url); $this->assert_true(!empty($comment->created)); + $this->assert_equal("1.1.1.1", $comment->ip_addr); + $this->assert_equal("Gallery3 Unit Test", $comment->user_agent); comment::update($comment, $rand, $rand, $rand, $rand, $rand); $this->assert_equal($rand, $comment->author); @@ -67,5 +98,7 @@ class Comment_Helper_Test extends Unit_Test_Case { $this->assert_equal($rand, $comment->text); $this->assert_equal($rand, $comment->item_id); $this->assert_equal($rand, $comment->url); + $this->assert_equal("1.1.1.1", $comment->ip_addr); + $this->assert_equal("Gallery3 Unit Test", $comment->user_agent); } } |