summaryrefslogtreecommitdiff
path: root/tests/units/Validator/CommentValidatorTest.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-01-14 20:18:13 -0500
committerFrederic Guillot <fred@kanboard.net>2016-01-14 20:18:13 -0500
commit805be7d33155478ef32c4bd3643dcf4025d85a05 (patch)
tree4ee858d96f3e3bf2b630471db148446c3c56b693 /tests/units/Validator/CommentValidatorTest.php
parentdc35a78374e9b091505cfc56eefcd0c631c56e3a (diff)
Move validator methods
Diffstat (limited to 'tests/units/Validator/CommentValidatorTest.php')
-rw-r--r--tests/units/Validator/CommentValidatorTest.php57
1 files changed, 57 insertions, 0 deletions
diff --git a/tests/units/Validator/CommentValidatorTest.php b/tests/units/Validator/CommentValidatorTest.php
new file mode 100644
index 00000000..378fe924
--- /dev/null
+++ b/tests/units/Validator/CommentValidatorTest.php
@@ -0,0 +1,57 @@
+<?php
+
+require_once __DIR__.'/../Base.php';
+
+use Kanboard\Validator\CommentValidator;
+
+class CommentValidatorTest extends Base
+{
+ public function testValidateCreation()
+ {
+ $validator = new CommentValidator($this->container);
+
+ $result = $validator->validateCreation(array('user_id' => 1, 'task_id' => 1, 'comment' => 'bla'));
+ $this->assertTrue($result[0]);
+
+ $result = $validator->validateCreation(array('user_id' => 1, 'task_id' => 1, 'comment' => ''));
+ $this->assertFalse($result[0]);
+
+ $result = $validator->validateCreation(array('user_id' => 1, 'task_id' => 'a', 'comment' => 'bla'));
+ $this->assertFalse($result[0]);
+
+ $result = $validator->validateCreation(array('user_id' => 'b', 'task_id' => 1, 'comment' => 'bla'));
+ $this->assertFalse($result[0]);
+
+ $result = $validator->validateCreation(array('user_id' => 1, 'comment' => 'bla'));
+ $this->assertFalse($result[0]);
+
+ $result = $validator->validateCreation(array('task_id' => 1, 'comment' => 'bla'));
+ $this->assertTrue($result[0]);
+
+ $result = $validator->validateCreation(array('comment' => 'bla'));
+ $this->assertFalse($result[0]);
+
+ $result = $validator->validateCreation(array());
+ $this->assertFalse($result[0]);
+ }
+
+ public function testValidateModification()
+ {
+ $validator = new CommentValidator($this->container);
+
+ $result = $validator->validateModification(array('id' => 1, 'comment' => 'bla'));
+ $this->assertTrue($result[0]);
+
+ $result = $validator->validateModification(array('id' => 1, 'comment' => ''));
+ $this->assertFalse($result[0]);
+
+ $result = $validator->validateModification(array('comment' => 'bla'));
+ $this->assertFalse($result[0]);
+
+ $result = $validator->validateModification(array('id' => 'b', 'comment' => 'bla'));
+ $this->assertFalse($result[0]);
+
+ $result = $validator->validateModification(array());
+ $this->assertFalse($result[0]);
+ }
+}