summaryrefslogtreecommitdiff
path: root/tests/units/Model/SubtaskTest.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-05-17 22:08:57 -0400
committerFrederic Guillot <fred@kanboard.net>2016-05-17 22:08:57 -0400
commit996997a12d1b435956a96640eb6cf39045f6ef46 (patch)
tree1512126636270a97b22a7ace83657289fc55a4c4 /tests/units/Model/SubtaskTest.php
parentd8472d17bd1cd0aa996b6f19288e5e799a78ad65 (diff)
Added the possibility to convert a subtask to a task
Diffstat (limited to 'tests/units/Model/SubtaskTest.php')
-rw-r--r--tests/units/Model/SubtaskTest.php25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/units/Model/SubtaskTest.php b/tests/units/Model/SubtaskTest.php
index eb9747d4..20186452 100644
--- a/tests/units/Model/SubtaskTest.php
+++ b/tests/units/Model/SubtaskTest.php
@@ -6,6 +6,7 @@ use Kanboard\Model\TaskCreation;
use Kanboard\Model\Subtask;
use Kanboard\Model\Project;
use Kanboard\Core\User\UserSession;
+use Kanboard\Model\TaskFinder;
class SubtaskTest extends Base
{
@@ -360,4 +361,28 @@ class SubtaskTest extends Base
$this->assertFalse($subtaskModel->changePosition(1, 2, 0));
$this->assertFalse($subtaskModel->changePosition(1, 2, 4));
}
+
+ public function testConvertToTask()
+ {
+ $taskCreationModel = new TaskCreation($this->container);
+ $taskFinderModel = new TaskFinder($this->container);
+ $subtaskModel = new Subtask($this->container);
+ $projectModel = new Project($this->container);
+
+ $this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
+ $this->assertEquals(1, $taskCreationModel->create(array('title' => 'test 1', 'project_id' => 1)));
+
+ $this->assertEquals(1, $subtaskModel->create(array('title' => 'subtask #1', 'task_id' => 1, 'user_id' => 1, 'time_spent' => 2, 'time_estimated' => 3)));
+ $task_id = $subtaskModel->convertToTask(1, 1);
+
+ $this->assertNotFalse($task_id);
+ $this->assertEmpty($subtaskModel->getById(1));
+
+ $task = $taskFinderModel->getById($task_id);
+ $this->assertEquals('subtask #1', $task['title']);
+ $this->assertEquals(1, $task['project_id']);
+ $this->assertEquals(1, $task['owner_id']);
+ $this->assertEquals(2, $task['time_spent']);
+ $this->assertEquals(3, $task['time_estimated']);
+ }
}