From 2a42e0e1aae35a9bb7abf054155b516ffab701d4 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sat, 23 Jul 2016 18:10:05 -0400 Subject: Added a new automatic action to set due date --- .../Action/TaskAssignDueDateOnCreationTest.php | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 tests/units/Action/TaskAssignDueDateOnCreationTest.php (limited to 'tests/units/Action/TaskAssignDueDateOnCreationTest.php') diff --git a/tests/units/Action/TaskAssignDueDateOnCreationTest.php b/tests/units/Action/TaskAssignDueDateOnCreationTest.php new file mode 100644 index 00000000..26c0584e --- /dev/null +++ b/tests/units/Action/TaskAssignDueDateOnCreationTest.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'))); + + $event = TaskEventBuilder::getInstance($this->container) + ->withTaskId(1) + ->buildEvent(); + + $action = new TaskAssignDueDateOnCreation($this->container); + $action->setProjectId(1); + $action->setParam('duration', 4); + + $this->assertTrue($action->execute($event, TaskModel::EVENT_CREATE)); + + $task = $taskFinderModel->getById(1); + $this->assertNotEmpty($task); + $this->assertEquals(date('Y-m-d', strtotime('+4days')), date('Y-m-d', $task['date_due'])); + } +} -- cgit v1.2.3