summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Andres <thomas@andres.in>2017-03-16 22:45:08 +0100
committerThomas Andres <thomas@andres.in>2017-03-16 22:45:08 +0100
commit0c378e2b5186175dd664145dcb9f83498c78b929 (patch)
tree583afe907f841e0a9320ec039ab0ef66f8921abc
parentad0cee20c199f5432affca90a320583677bb1e04 (diff)
added dates to unit tests
-rw-r--r--tests/units/Validator/TaskValidatorTest.php52
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/units/Validator/TaskValidatorTest.php b/tests/units/Validator/TaskValidatorTest.php
index 0c7fead7..5c1b9a52 100644
--- a/tests/units/Validator/TaskValidatorTest.php
+++ b/tests/units/Validator/TaskValidatorTest.php
@@ -67,4 +67,56 @@ class TaskValidatorTest extends Base
$result = $taskValidator->validateCreation(array('project_id' => 1, 'title' => 'test', 'swimlane_id' => 0));
$this->assertFalse($result[0]);
}
+
+ public function testDateField()
+ {
+ $taskValidator = new TaskValidator($this->container);
+
+ // date_due
+ // ISO dates
+ $result = $taskValidator->validateCreation(array('project_id' => 1, 'title' => 'test', 'date_due' => '2017-02-01'));
+ $this->assertTrue($result[0]);
+ $result = $taskValidator->validateCreation(array('project_id' => 1, 'title' => 'test', 'date_due' => '2017-02-01 13:15'));
+ $this->assertTrue($result[0]);
+ $result = $taskValidator->validateCreation(array('project_id' => 1, 'title' => 'test', 'date_due' => '2017-02-01 1:15 pm'));
+ $this->assertFalse($result[0]);
+ $result = $taskValidator->validateCreation(array('project_id' => 1, 'title' => 'test', 'date_due' => '2017_02_01'));
+ $this->assertTrue($result[0]);
+ $result = $taskValidator->validateCreation(array('project_id' => 1, 'title' => 'test', 'date_due' => '2017_02_01 13:15'));
+ $this->assertTrue($result[0]);
+ $result = $taskValidator->validateCreation(array('project_id' => 1, 'title' => 'test', 'date_due' => '2017_02_01 1:15 am'));
+ $this->assertFalse($result[0]);
+
+ // d/m/Y dates
+ $result = $taskValidator->validateCreation(array('project_id' => 1, 'title' => 'test', 'date_due' => '02/01/2017'));
+ $this->assertTrue($result[0]);
+ $result = $taskValidator->validateCreation(array('project_id' => 1, 'title' => 'test', 'date_due' => '02/01/2017 13:15'));
+ $this->assertTrue($result[0]);
+ $result = $taskValidator->validateCreation(array('project_id' => 1, 'title' => 'test', 'date_due' => '02/01/2017 1:15 pm'));
+ $this->assertFalse($result[0]);
+
+
+ // date_started
+ // ISO dates
+ $result = $taskValidator->validateCreation(array('project_id' => 1, 'title' => 'test', 'date_started' => '2017-02-01'));
+ $this->assertTrue($result[0]);
+ $result = $taskValidator->validateCreation(array('project_id' => 1, 'title' => 'test', 'date_started' => '2017-02-01 13:15'));
+ $this->assertTrue($result[0]);
+ $result = $taskValidator->validateCreation(array('project_id' => 1, 'title' => 'test', 'date_started' => '2017-02-01 1:15 pm'));
+ $this->assertFalse($result[0]);
+ $result = $taskValidator->validateCreation(array('project_id' => 1, 'title' => 'test', 'date_started' => '2017_02_01'));
+ $this->assertTrue($result[0]);
+ $result = $taskValidator->validateCreation(array('project_id' => 1, 'title' => 'test', 'date_started' => '2017_02_01 13:15'));
+ $this->assertTrue($result[0]);
+ $result = $taskValidator->validateCreation(array('project_id' => 1, 'title' => 'test', 'date_started' => '2017_02_01 1:15 pm'));
+ $this->assertFalse($result[0]);
+
+ // d/m/Y dates
+ $result = $taskValidator->validateCreation(array('project_id' => 1, 'title' => 'test', 'date_started' => '02/01/2017'));
+ $this->assertTrue($result[0]);
+ $result = $taskValidator->validateCreation(array('project_id' => 1, 'title' => 'test', 'date_started' => '02/01/2017 13:15'));
+ $this->assertTrue($result[0]);
+ $result = $taskValidator->validateCreation(array('project_id' => 1, 'title' => 'test', 'date_started' => '02/01/2017 1:15 pm'));
+ $this->assertFalse($result[0]);
+ }
}