summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/units/Model/TaskDuplicationModelTest.php (renamed from tests/units/Model/TaskDuplicationTest.php)2
-rw-r--r--tests/units/Model/TaskModelTest.php30
-rw-r--r--tests/units/Model/TaskRecurrenceModelTest.php36
-rw-r--r--tests/units/Model/TaskTest.php58
4 files changed, 67 insertions, 59 deletions
diff --git a/tests/units/Model/TaskDuplicationTest.php b/tests/units/Model/TaskDuplicationModelTest.php
index 7ce851d0..f5b8c540 100644
--- a/tests/units/Model/TaskDuplicationTest.php
+++ b/tests/units/Model/TaskDuplicationModelTest.php
@@ -10,7 +10,7 @@ use Kanboard\Model\ProjectModel;
use Kanboard\Model\CategoryModel;
use Kanboard\Model\TaskTagModel;
-class TaskDuplicationTest extends Base
+class TaskDuplicationModelTest extends Base
{
public function testThatDuplicateDefineCreator()
{
diff --git a/tests/units/Model/TaskModelTest.php b/tests/units/Model/TaskModelTest.php
new file mode 100644
index 00000000..e42b5ae6
--- /dev/null
+++ b/tests/units/Model/TaskModelTest.php
@@ -0,0 +1,30 @@
+<?php
+
+require_once __DIR__.'/../Base.php';
+
+use Kanboard\Model\TaskModel;
+use Kanboard\Model\TaskCreationModel;
+use Kanboard\Model\ProjectModel;
+
+class TaskModelTest extends Base
+{
+ public function testRemove()
+ {
+ $taskModel = new TaskModel($this->container);
+ $taskCreationModel = new TaskCreationModel($this->container);
+ $projectModel = new ProjectModel($this->container);
+
+ $this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest')));
+ $this->assertEquals(1, $taskCreationModel->create(array('title' => 'Task #1', 'project_id' => 1)));
+
+ $this->assertTrue($taskModel->remove(1));
+ $this->assertFalse($taskModel->remove(1234));
+ }
+
+ public function testGetTaskIdFromText()
+ {
+ $taskModel = new TaskModel($this->container);
+ $this->assertEquals(123, $taskModel->getTaskIdFromText('My task #123'));
+ $this->assertEquals(0, $taskModel->getTaskIdFromText('My task 123'));
+ }
+}
diff --git a/tests/units/Model/TaskRecurrenceModelTest.php b/tests/units/Model/TaskRecurrenceModelTest.php
index 6970e30f..85d77bc2 100644
--- a/tests/units/Model/TaskRecurrenceModelTest.php
+++ b/tests/units/Model/TaskRecurrenceModelTest.php
@@ -8,9 +8,38 @@ use Kanboard\Model\TaskCreationModel;
use Kanboard\Model\TaskFinderModel;
use Kanboard\Model\TaskModel;
use Kanboard\Model\TaskRecurrenceModel;
+use Kanboard\Model\TaskTagModel;
class TaskRecurrenceModelTest extends Base
{
+ public function testRecurrenceSettings()
+ {
+ $taskRecurrenceModel = new TaskRecurrenceModel($this->container);
+
+ $statuses = $taskRecurrenceModel->getRecurrenceStatusList();
+ $this->assertCount(2, $statuses);
+ $this->assertArrayHasKey(TaskModel::RECURRING_STATUS_NONE, $statuses);
+ $this->assertArrayHasKey(TaskModel::RECURRING_STATUS_PENDING, $statuses);
+ $this->assertArrayNotHasKey(TaskModel::RECURRING_STATUS_PROCESSED, $statuses);
+
+ $triggers = $taskRecurrenceModel->getRecurrenceTriggerList();
+ $this->assertCount(3, $triggers);
+ $this->assertArrayHasKey(TaskModel::RECURRING_TRIGGER_FIRST_COLUMN, $triggers);
+ $this->assertArrayHasKey(TaskModel::RECURRING_TRIGGER_LAST_COLUMN, $triggers);
+ $this->assertArrayHasKey(TaskModel::RECURRING_TRIGGER_CLOSE, $triggers);
+
+ $dates = $taskRecurrenceModel->getRecurrenceBasedateList();
+ $this->assertCount(2, $dates);
+ $this->assertArrayHasKey(TaskModel::RECURRING_BASEDATE_DUEDATE, $dates);
+ $this->assertArrayHasKey(TaskModel::RECURRING_BASEDATE_TRIGGERDATE, $dates);
+
+ $timeframes = $taskRecurrenceModel->getRecurrenceTimeframeList();
+ $this->assertCount(3, $timeframes);
+ $this->assertArrayHasKey(TaskModel::RECURRING_TIMEFRAME_DAYS, $timeframes);
+ $this->assertArrayHasKey(TaskModel::RECURRING_TIMEFRAME_MONTHS, $timeframes);
+ $this->assertArrayHasKey(TaskModel::RECURRING_TIMEFRAME_YEARS, $timeframes);
+ }
+
public function testCalculateRecurringTaskDueDate()
{
$taskRecurrenceModel = new TaskRecurrenceModel($this->container);
@@ -55,6 +84,7 @@ class TaskRecurrenceModelTest extends Base
$taskFinderModel = new TaskFinderModel($this->container);
$projectModel = new ProjectModel($this->container);
$dateParser = new DateParser($this->container);
+ $taskTagModel = new TaskTagModel($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
@@ -67,6 +97,7 @@ class TaskRecurrenceModelTest extends Base
'recurrence_factor' => 2,
'recurrence_timeframe' => TaskModel::RECURRING_TIMEFRAME_DAYS,
'recurrence_basedate' => TaskModel::RECURRING_BASEDATE_TRIGGERDATE,
+ 'tags' => array('T1', 'T2'),
)));
$this->assertEquals(2, $taskRecurrenceModel->duplicateRecurringTask(1));
@@ -86,5 +117,10 @@ class TaskRecurrenceModelTest extends Base
$this->assertEquals(1, $task['recurrence_parent']);
$this->assertEquals(2, $task['recurrence_factor']);
$this->assertEquals($dateParser->removeTimeFromTimestamp(strtotime('+2 days')), $task['date_due'], '', 2);
+
+ $tags = $taskTagModel->getList(2);
+ $this->assertCount(2, $tags);
+ $this->assertArrayHasKey(1, $tags);
+ $this->assertArrayHasKey(2, $tags);
}
}
diff --git a/tests/units/Model/TaskTest.php b/tests/units/Model/TaskTest.php
deleted file mode 100644
index 89fc4dc1..00000000
--- a/tests/units/Model/TaskTest.php
+++ /dev/null
@@ -1,58 +0,0 @@
-<?php
-
-require_once __DIR__.'/../Base.php';
-
-use Kanboard\Model\TaskModel;
-use Kanboard\Model\TaskCreationModel;
-use Kanboard\Model\ProjectModel;
-
-class TaskTest extends Base
-{
- public function testRemove()
- {
- $t = new TaskModel($this->container);
- $tc = new TaskCreationModel($this->container);
- $p = new ProjectModel($this->container);
-
- $this->assertEquals(1, $p->create(array('name' => 'UnitTest')));
- $this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1)));
-
- $this->assertTrue($t->remove(1));
- $this->assertFalse($t->remove(1234));
- }
-
- public function testGetTaskIdFromText()
- {
- $t = new TaskModel($this->container);
- $this->assertEquals(123, $t->getTaskIdFromText('My task #123'));
- $this->assertEquals(0, $t->getTaskIdFromText('My task 123'));
- }
-
- public function testRecurrenceSettings()
- {
- $t = new TaskModel($this->container);
-
- $statuses = $t->getRecurrenceStatusList();
- $this->assertCount(2, $statuses);
- $this->assertArrayHasKey(TaskModel::RECURRING_STATUS_NONE, $statuses);
- $this->assertArrayHasKey(TaskModel::RECURRING_STATUS_PENDING, $statuses);
- $this->assertArrayNotHasKey(TaskModel::RECURRING_STATUS_PROCESSED, $statuses);
-
- $triggers = $t->getRecurrenceTriggerList();
- $this->assertCount(3, $triggers);
- $this->assertArrayHasKey(TaskModel::RECURRING_TRIGGER_FIRST_COLUMN, $triggers);
- $this->assertArrayHasKey(TaskModel::RECURRING_TRIGGER_LAST_COLUMN, $triggers);
- $this->assertArrayHasKey(TaskModel::RECURRING_TRIGGER_CLOSE, $triggers);
-
- $dates = $t->getRecurrenceBasedateList();
- $this->assertCount(2, $dates);
- $this->assertArrayHasKey(TaskModel::RECURRING_BASEDATE_DUEDATE, $dates);
- $this->assertArrayHasKey(TaskModel::RECURRING_BASEDATE_TRIGGERDATE, $dates);
-
- $timeframes = $t->getRecurrenceTimeframeList();
- $this->assertCount(3, $timeframes);
- $this->assertArrayHasKey(TaskModel::RECURRING_TIMEFRAME_DAYS, $timeframes);
- $this->assertArrayHasKey(TaskModel::RECURRING_TIMEFRAME_MONTHS, $timeframes);
- $this->assertArrayHasKey(TaskModel::RECURRING_TIMEFRAME_YEARS, $timeframes);
- }
-}