summaryrefslogtreecommitdiff
path: root/tests/units/Validator/TaskValidatorTest.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-10-08 09:58:11 -0400
committerFrederic Guillot <fred@kanboard.net>2016-10-08 09:58:11 -0400
commitc2f1cc8f7419fe4eb5e9bd5e6ce05d90e719be17 (patch)
tree93900cc242574a346f14e2002f050b5f2c7dc55e /tests/units/Validator/TaskValidatorTest.php
parent1466afb771f0291bc350441aede14c97459128e7 (diff)
Restrict task complexity to a specific range to avoid integer overflow
Diffstat (limited to 'tests/units/Validator/TaskValidatorTest.php')
-rw-r--r--tests/units/Validator/TaskValidatorTest.php42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/units/Validator/TaskValidatorTest.php b/tests/units/Validator/TaskValidatorTest.php
new file mode 100644
index 00000000..f6530027
--- /dev/null
+++ b/tests/units/Validator/TaskValidatorTest.php
@@ -0,0 +1,42 @@
+<?php
+
+require_once __DIR__.'/../Base.php';
+
+use Kanboard\Validator\TaskValidator;
+
+class TaskValidatorTest extends Base
+{
+ public function testRequiredFields()
+ {
+ $taskValidator = new TaskValidator($this->container);
+
+ $result = $taskValidator->validateCreation(array('project_id' => 1, 'title' => 'test'));
+ $this->assertTrue($result[0]);
+
+ $result = $taskValidator->validateCreation(array('project_id' => 1));
+ $this->assertFalse($result[0]);
+
+ $result = $taskValidator->validateCreation(array('title' => 'test'));
+ $this->assertFalse($result[0]);
+ }
+
+ public function testRangeFields()
+ {
+ $taskValidator = new TaskValidator($this->container);
+
+ $result = $taskValidator->validateCreation(array('project_id' => 1, 'title' => 'test', 'score' => 2147483647));
+ $this->assertTrue($result[0]);
+
+ $result = $taskValidator->validateCreation(array('project_id' => 1, 'title' => 'test', 'score' => -2147483647));
+ $this->assertTrue($result[0]);
+
+ $result = $taskValidator->validateCreation(array('project_id' => 1, 'title' => 'test', 'score' => 0));
+ $this->assertTrue($result[0]);
+
+ $result = $taskValidator->validateCreation(array('project_id' => 1, 'title' => 'test', 'score' => 2147483648));
+ $this->assertFalse($result[0]);
+
+ $result = $taskValidator->validateCreation(array('project_id' => 1, 'title' => 'test', 'score' => -2147483648));
+ $this->assertFalse($result[0]);
+ }
+}