From 3fcc0cb9183f9ff32ce7a3c615258bcf53c385ed Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sat, 2 Jul 2016 14:44:26 -0400 Subject: Handle tags and tasks move/duplication to another project --- app/Model/TaskRecurrenceModel.php | 87 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 app/Model/TaskRecurrenceModel.php (limited to 'app/Model/TaskRecurrenceModel.php') diff --git a/app/Model/TaskRecurrenceModel.php b/app/Model/TaskRecurrenceModel.php new file mode 100644 index 00000000..a5f2ab90 --- /dev/null +++ b/app/Model/TaskRecurrenceModel.php @@ -0,0 +1,87 @@ +copyFields($task_id); + + if ($values['recurrence_status'] == TaskModel::RECURRING_STATUS_PENDING) { + $values['recurrence_parent'] = $task_id; + $values['column_id'] = $this->columnModel->getFirstColumnId($values['project_id']); + $this->calculateRecurringTaskDueDate($values); + + $recurring_task_id = $this->save($task_id, $values); + + if ($recurring_task_id > 0) { + $parent_update = $this->db + ->table(TaskModel::TABLE) + ->eq('id', $task_id) + ->update(array( + 'recurrence_status' => TaskModel::RECURRING_STATUS_PROCESSED, + 'recurrence_child' => $recurring_task_id, + )); + + if ($parent_update) { + return $recurring_task_id; + } + } + } + + return false; + } + + /** + * Calculate new due date for new recurrence task + * + * @access public + * @param array $values Task fields + */ + public function calculateRecurringTaskDueDate(array &$values) + { + if (! empty($values['date_due']) && $values['recurrence_factor'] != 0) { + if ($values['recurrence_basedate'] == TaskModel::RECURRING_BASEDATE_TRIGGERDATE) { + $values['date_due'] = time(); + } + + $factor = abs($values['recurrence_factor']); + $subtract = $values['recurrence_factor'] < 0; + + switch ($values['recurrence_timeframe']) { + case TaskModel::RECURRING_TIMEFRAME_MONTHS: + $interval = 'P' . $factor . 'M'; + break; + case TaskModel::RECURRING_TIMEFRAME_YEARS: + $interval = 'P' . $factor . 'Y'; + break; + default: + $interval = 'P' . $factor . 'D'; + } + + $date_due = new DateTime(); + $date_due->setTimestamp($values['date_due']); + + $subtract ? $date_due->sub(new DateInterval($interval)) : $date_due->add(new DateInterval($interval)); + + $values['date_due'] = $date_due->getTimestamp(); + } + } +} -- cgit v1.2.3 From 8e56148a6dda1f6b1a78a759e69e600b79bdddd2 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sat, 2 Jul 2016 15:45:55 -0400 Subject: Make sure that tags are duplicated for recurring tasks --- app/Controller/BoardTooltipController.php | 6 +- app/Controller/TaskRecurrenceController.php | 8 +- app/Helper/TaskHelper.php | 6 +- app/Model/TaskModel.php | 60 +----------- app/Model/TaskRecurrenceModel.php | 62 ++++++++++++- tests/units/Model/TaskDuplicationModelTest.php | 121 +++++++++++++++++++++++++ tests/units/Model/TaskDuplicationTest.php | 121 ------------------------- tests/units/Model/TaskModelTest.php | 30 ++++++ tests/units/Model/TaskRecurrenceModelTest.php | 36 ++++++++ tests/units/Model/TaskTest.php | 58 ------------ 10 files changed, 259 insertions(+), 249 deletions(-) create mode 100644 tests/units/Model/TaskDuplicationModelTest.php delete mode 100644 tests/units/Model/TaskDuplicationTest.php create mode 100644 tests/units/Model/TaskModelTest.php delete mode 100644 tests/units/Model/TaskTest.php (limited to 'app/Model/TaskRecurrenceModel.php') diff --git a/app/Controller/BoardTooltipController.php b/app/Controller/BoardTooltipController.php index 2a947027..134d728e 100644 --- a/app/Controller/BoardTooltipController.php +++ b/app/Controller/BoardTooltipController.php @@ -107,9 +107,9 @@ class BoardTooltipController extends BaseController $this->response->html($this->template->render('task_recurrence/info', array( 'task' => $task, - 'recurrence_trigger_list' => $this->taskModel->getRecurrenceTriggerList(), - 'recurrence_timeframe_list' => $this->taskModel->getRecurrenceTimeframeList(), - 'recurrence_basedate_list' => $this->taskModel->getRecurrenceBasedateList(), + 'recurrence_trigger_list' => $this->taskRecurrenceModel->getRecurrenceTriggerList(), + 'recurrence_timeframe_list' => $this->taskRecurrenceModel->getRecurrenceTimeframeList(), + 'recurrence_basedate_list' => $this->taskRecurrenceModel->getRecurrenceBasedateList(), ))); } diff --git a/app/Controller/TaskRecurrenceController.php b/app/Controller/TaskRecurrenceController.php index dc7a0e1b..c6fdfa37 100644 --- a/app/Controller/TaskRecurrenceController.php +++ b/app/Controller/TaskRecurrenceController.php @@ -31,10 +31,10 @@ class TaskRecurrenceController extends BaseController 'values' => $values, 'errors' => $errors, 'task' => $task, - 'recurrence_status_list' => $this->taskModel->getRecurrenceStatusList(), - 'recurrence_trigger_list' => $this->taskModel->getRecurrenceTriggerList(), - 'recurrence_timeframe_list' => $this->taskModel->getRecurrenceTimeframeList(), - 'recurrence_basedate_list' => $this->taskModel->getRecurrenceBasedateList(), + 'recurrence_status_list' => $this->taskRecurrenceModel->getRecurrenceStatusList(), + 'recurrence_trigger_list' => $this->taskRecurrenceModel->getRecurrenceTriggerList(), + 'recurrence_timeframe_list' => $this->taskRecurrenceModel->getRecurrenceTimeframeList(), + 'recurrence_basedate_list' => $this->taskRecurrenceModel->getRecurrenceBasedateList(), ))); } diff --git a/app/Helper/TaskHelper.php b/app/Helper/TaskHelper.php index 84b41e42..e1d65cca 100644 --- a/app/Helper/TaskHelper.php +++ b/app/Helper/TaskHelper.php @@ -27,17 +27,17 @@ class TaskHelper extends Base public function recurrenceTriggers() { - return $this->taskModel->getRecurrenceTriggerList(); + return $this->taskRecurrenceModel->getRecurrenceTriggerList(); } public function recurrenceTimeframes() { - return $this->taskModel->getRecurrenceTimeframeList(); + return $this->taskRecurrenceModel->getRecurrenceTimeframeList(); } public function recurrenceBasedates() { - return $this->taskModel->getRecurrenceBasedateList(); + return $this->taskRecurrenceModel->getRecurrenceBasedateList(); } public function selectTitle(array $values, array $errors) diff --git a/app/Model/TaskModel.php b/app/Model/TaskModel.php index 5df41f3c..5cddb509 100644 --- a/app/Model/TaskModel.php +++ b/app/Model/TaskModel.php @@ -5,7 +5,7 @@ namespace Kanboard\Model; use Kanboard\Core\Base; /** - * Task model + * Task Model * * @package Kanboard\Model * @author Frederic Guillot @@ -117,64 +117,6 @@ class TaskModel extends Base return 0; } - /** - * Return the list user selectable recurrence status - * - * @access public - * @return array - */ - public function getRecurrenceStatusList() - { - return array( - TaskModel::RECURRING_STATUS_NONE => t('No'), - TaskModel::RECURRING_STATUS_PENDING => t('Yes'), - ); - } - - /** - * Return the list recurrence triggers - * - * @access public - * @return array - */ - public function getRecurrenceTriggerList() - { - return array( - TaskModel::RECURRING_TRIGGER_FIRST_COLUMN => t('When task is moved from first column'), - TaskModel::RECURRING_TRIGGER_LAST_COLUMN => t('When task is moved to last column'), - TaskModel::RECURRING_TRIGGER_CLOSE => t('When task is closed'), - ); - } - - /** - * Return the list options to calculate recurrence due date - * - * @access public - * @return array - */ - public function getRecurrenceBasedateList() - { - return array( - TaskModel::RECURRING_BASEDATE_DUEDATE => t('Existing due date'), - TaskModel::RECURRING_BASEDATE_TRIGGERDATE => t('Action date'), - ); - } - - /** - * Return the list recurrence timeframes - * - * @access public - * @return array - */ - public function getRecurrenceTimeframeList() - { - return array( - TaskModel::RECURRING_TIMEFRAME_DAYS => t('Day(s)'), - TaskModel::RECURRING_TIMEFRAME_MONTHS => t('Month(s)'), - TaskModel::RECURRING_TIMEFRAME_YEARS => t('Year(s)'), - ); - } - /** * Get task progress based on the column position * diff --git a/app/Model/TaskRecurrenceModel.php b/app/Model/TaskRecurrenceModel.php index a5f2ab90..ffe43f8c 100644 --- a/app/Model/TaskRecurrenceModel.php +++ b/app/Model/TaskRecurrenceModel.php @@ -13,6 +13,64 @@ use DateTime; */ class TaskRecurrenceModel extends TaskDuplicationModel { + /** + * Return the list user selectable recurrence status + * + * @access public + * @return array + */ + public function getRecurrenceStatusList() + { + return array( + TaskModel::RECURRING_STATUS_NONE => t('No'), + TaskModel::RECURRING_STATUS_PENDING => t('Yes'), + ); + } + + /** + * Return the list recurrence triggers + * + * @access public + * @return array + */ + public function getRecurrenceTriggerList() + { + return array( + TaskModel::RECURRING_TRIGGER_FIRST_COLUMN => t('When task is moved from first column'), + TaskModel::RECURRING_TRIGGER_LAST_COLUMN => t('When task is moved to last column'), + TaskModel::RECURRING_TRIGGER_CLOSE => t('When task is closed'), + ); + } + + /** + * Return the list options to calculate recurrence due date + * + * @access public + * @return array + */ + public function getRecurrenceBasedateList() + { + return array( + TaskModel::RECURRING_BASEDATE_DUEDATE => t('Existing due date'), + TaskModel::RECURRING_BASEDATE_TRIGGERDATE => t('Action date'), + ); + } + + /** + * Return the list recurrence timeframes + * + * @access public + * @return array + */ + public function getRecurrenceTimeframeList() + { + return array( + TaskModel::RECURRING_TIMEFRAME_DAYS => t('Day(s)'), + TaskModel::RECURRING_TIMEFRAME_MONTHS => t('Month(s)'), + TaskModel::RECURRING_TIMEFRAME_YEARS => t('Year(s)'), + ); + } + /** * Duplicate recurring task * @@ -31,7 +89,9 @@ class TaskRecurrenceModel extends TaskDuplicationModel $recurring_task_id = $this->save($task_id, $values); - if ($recurring_task_id > 0) { + if ($recurring_task_id !== false) { + $this->tagDuplicationModel->duplicateTaskTags($task_id, $recurring_task_id); + $parent_update = $this->db ->table(TaskModel::TABLE) ->eq('id', $task_id) diff --git a/tests/units/Model/TaskDuplicationModelTest.php b/tests/units/Model/TaskDuplicationModelTest.php new file mode 100644 index 00000000..f5b8c540 --- /dev/null +++ b/tests/units/Model/TaskDuplicationModelTest.php @@ -0,0 +1,121 @@ +container); + $taskCreationModel = new TaskCreationModel($this->container); + $taskFinderModel = new TaskFinderModel($this->container); + $projectModel = new ProjectModel($this->container); + + $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); + $this->assertEquals(1, $taskCreationModel->create(array('title' => 'test', 'project_id' => 1))); + + $task = $taskFinderModel->getById(1); + $this->assertNotEmpty($task); + $this->assertEquals(1, $task['position']); + $this->assertEquals(1, $task['project_id']); + $this->assertEquals(0, $task['creator_id']); + + $this->container['sessionStorage']->user = array('id' => 1); + + // We duplicate our task + $this->assertEquals(2, $taskDuplicationModel->duplicate(1)); + + // Check the values of the duplicated task + $task = $taskFinderModel->getById(2); + $this->assertNotEmpty($task); + $this->assertEquals(1, $task['creator_id']); + } + + public function testDuplicateSameProject() + { + $taskDuplicationModel = new TaskDuplicationModel($this->container); + $taskCreationModel = new TaskCreationModel($this->container); + $taskFinderModel = new TaskFinderModel($this->container); + $projectModel = new ProjectModel($this->container); + $categoryModel = new CategoryModel($this->container); + + // We create a task and a project + $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); + + // Some categories + $this->assertNotFalse($categoryModel->create(array('name' => 'Category #1', 'project_id' => 1))); + $this->assertNotFalse($categoryModel->create(array('name' => 'Category #2', 'project_id' => 1))); + $this->assertTrue($categoryModel->exists(1)); + $this->assertTrue($categoryModel->exists(2)); + + $this->assertEquals(1, $taskCreationModel->create(array( + 'title' => 'test', + 'project_id' => 1, + 'column_id' => 3, + 'owner_id' => 1, + 'category_id' => 2, + 'time_spent' => 4.4 + ))); + + $task = $taskFinderModel->getById(1); + $this->assertNotEmpty($task); + $this->assertEquals(1, $task['position']); + $this->assertEquals(1, $task['project_id']); + $this->assertEquals(3, $task['column_id']); + $this->assertEquals(2, $task['category_id']); + $this->assertEquals(4.4, $task['time_spent']); + + $this->container['dispatcher']->addListener(TaskModel::EVENT_CREATE_UPDATE, function () {}); + $this->container['dispatcher']->addListener(TaskModel::EVENT_CREATE, function () {}); + + // We duplicate our task + $this->assertEquals(2, $taskDuplicationModel->duplicate(1)); + + $called = $this->container['dispatcher']->getCalledListeners(); + $this->assertArrayHasKey(TaskModel::EVENT_CREATE_UPDATE.'.closure', $called); + $this->assertArrayHasKey(TaskModel::EVENT_CREATE.'.closure', $called); + + // Check the values of the duplicated task + $task = $taskFinderModel->getById(2); + $this->assertNotEmpty($task); + $this->assertEquals(TaskModel::STATUS_OPEN, $task['is_active']); + $this->assertEquals(1, $task['project_id']); + $this->assertEquals(1, $task['owner_id']); + $this->assertEquals(2, $task['category_id']); + $this->assertEquals(0, $task['swimlane_id']); + $this->assertEquals(3, $task['column_id']); + $this->assertEquals(2, $task['position']); + $this->assertEquals('test', $task['title']); + $this->assertEquals(0, $task['time_spent']); + } + + public function testDuplicateSameProjectWitTags() + { + $taskDuplicationModel = new TaskDuplicationModel($this->container); + $taskCreationModel = new TaskCreationModel($this->container); + $projectModel = new ProjectModel($this->container); + $taskTagModel = new TaskTagModel($this->container); + + $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); + $this->assertEquals(1, $taskCreationModel->create(array( + 'title' => 'test', + 'project_id' => 1, + 'tags' => array('T1', 'T2') + ))); + + $this->assertEquals(2, $taskDuplicationModel->duplicate(1)); + + $tags = $taskTagModel->getList(2); + $this->assertCount(2, $tags); + $this->assertArrayHasKey(1, $tags); + $this->assertArrayHasKey(2, $tags); + } +} diff --git a/tests/units/Model/TaskDuplicationTest.php b/tests/units/Model/TaskDuplicationTest.php deleted file mode 100644 index 7ce851d0..00000000 --- a/tests/units/Model/TaskDuplicationTest.php +++ /dev/null @@ -1,121 +0,0 @@ -container); - $taskCreationModel = new TaskCreationModel($this->container); - $taskFinderModel = new TaskFinderModel($this->container); - $projectModel = new ProjectModel($this->container); - - $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); - $this->assertEquals(1, $taskCreationModel->create(array('title' => 'test', 'project_id' => 1))); - - $task = $taskFinderModel->getById(1); - $this->assertNotEmpty($task); - $this->assertEquals(1, $task['position']); - $this->assertEquals(1, $task['project_id']); - $this->assertEquals(0, $task['creator_id']); - - $this->container['sessionStorage']->user = array('id' => 1); - - // We duplicate our task - $this->assertEquals(2, $taskDuplicationModel->duplicate(1)); - - // Check the values of the duplicated task - $task = $taskFinderModel->getById(2); - $this->assertNotEmpty($task); - $this->assertEquals(1, $task['creator_id']); - } - - public function testDuplicateSameProject() - { - $taskDuplicationModel = new TaskDuplicationModel($this->container); - $taskCreationModel = new TaskCreationModel($this->container); - $taskFinderModel = new TaskFinderModel($this->container); - $projectModel = new ProjectModel($this->container); - $categoryModel = new CategoryModel($this->container); - - // We create a task and a project - $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); - - // Some categories - $this->assertNotFalse($categoryModel->create(array('name' => 'Category #1', 'project_id' => 1))); - $this->assertNotFalse($categoryModel->create(array('name' => 'Category #2', 'project_id' => 1))); - $this->assertTrue($categoryModel->exists(1)); - $this->assertTrue($categoryModel->exists(2)); - - $this->assertEquals(1, $taskCreationModel->create(array( - 'title' => 'test', - 'project_id' => 1, - 'column_id' => 3, - 'owner_id' => 1, - 'category_id' => 2, - 'time_spent' => 4.4 - ))); - - $task = $taskFinderModel->getById(1); - $this->assertNotEmpty($task); - $this->assertEquals(1, $task['position']); - $this->assertEquals(1, $task['project_id']); - $this->assertEquals(3, $task['column_id']); - $this->assertEquals(2, $task['category_id']); - $this->assertEquals(4.4, $task['time_spent']); - - $this->container['dispatcher']->addListener(TaskModel::EVENT_CREATE_UPDATE, function () {}); - $this->container['dispatcher']->addListener(TaskModel::EVENT_CREATE, function () {}); - - // We duplicate our task - $this->assertEquals(2, $taskDuplicationModel->duplicate(1)); - - $called = $this->container['dispatcher']->getCalledListeners(); - $this->assertArrayHasKey(TaskModel::EVENT_CREATE_UPDATE.'.closure', $called); - $this->assertArrayHasKey(TaskModel::EVENT_CREATE.'.closure', $called); - - // Check the values of the duplicated task - $task = $taskFinderModel->getById(2); - $this->assertNotEmpty($task); - $this->assertEquals(TaskModel::STATUS_OPEN, $task['is_active']); - $this->assertEquals(1, $task['project_id']); - $this->assertEquals(1, $task['owner_id']); - $this->assertEquals(2, $task['category_id']); - $this->assertEquals(0, $task['swimlane_id']); - $this->assertEquals(3, $task['column_id']); - $this->assertEquals(2, $task['position']); - $this->assertEquals('test', $task['title']); - $this->assertEquals(0, $task['time_spent']); - } - - public function testDuplicateSameProjectWitTags() - { - $taskDuplicationModel = new TaskDuplicationModel($this->container); - $taskCreationModel = new TaskCreationModel($this->container); - $projectModel = new ProjectModel($this->container); - $taskTagModel = new TaskTagModel($this->container); - - $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); - $this->assertEquals(1, $taskCreationModel->create(array( - 'title' => 'test', - 'project_id' => 1, - 'tags' => array('T1', 'T2') - ))); - - $this->assertEquals(2, $taskDuplicationModel->duplicate(1)); - - $tags = $taskTagModel->getList(2); - $this->assertCount(2, $tags); - $this->assertArrayHasKey(1, $tags); - $this->assertArrayHasKey(2, $tags); - } -} 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 @@ +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 @@ -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); - } -} -- cgit v1.2.3