From 343e86a138648644870209708760c1e1f36805f7 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Thu, 23 Feb 2017 17:30:27 -0500 Subject: Automatic action to change task color when due date is expired (PR #3062) --- .../units/Action/TaskAssignColorOnDueDateTest.php | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 tests/units/Action/TaskAssignColorOnDueDateTest.php (limited to 'tests/units/Action') diff --git a/tests/units/Action/TaskAssignColorOnDueDateTest.php b/tests/units/Action/TaskAssignColorOnDueDateTest.php new file mode 100644 index 00000000..4bb87c06 --- /dev/null +++ b/tests/units/Action/TaskAssignColorOnDueDateTest.php @@ -0,0 +1,37 @@ +container); + $taskCreationModel = new TaskCreationModel($this->container); + $taskFinderModel = new TaskFinderModel($this->container); + + $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); + $this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test', 'date_due' => strtotime('-1 day')))); + $this->assertEquals(2, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test'))); + + $tasks = $taskFinderModel->getAll(1); + $event = new TaskListEvent(array('tasks' => $tasks, 'project_id' => 1)); + + $action = new TaskAssignColorOnDueDate($this->container); + $action->setProjectId(1); + $action->setParam('color_id', 'red'); + + $this->assertTrue($action->execute($event, TaskModel::EVENT_DAILY_CRONJOB)); + + $tasks = $taskFinderModel->getAll(1); + $this->assertEquals('red', $tasks[0]['color_id']); + $this->assertEquals('yellow', $tasks[1]['color_id']); + } +} -- cgit v1.2.3