summaryrefslogtreecommitdiff
path: root/tests/units/Model/TaskDuplicationTest.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-07-02 15:45:55 -0400
committerFrederic Guillot <fred@kanboard.net>2016-07-02 15:45:55 -0400
commit8e56148a6dda1f6b1a78a759e69e600b79bdddd2 (patch)
tree538d0704bae9a7baab1a8a6de2abb646da31bdac /tests/units/Model/TaskDuplicationTest.php
parentb7ac354e83af122e94cec1f9306aca6355a02a39 (diff)
Make sure that tags are duplicated for recurring tasks
Diffstat (limited to 'tests/units/Model/TaskDuplicationTest.php')
-rw-r--r--tests/units/Model/TaskDuplicationTest.php121
1 files changed, 0 insertions, 121 deletions
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 @@
-<?php
-
-require_once __DIR__.'/../Base.php';
-
-use Kanboard\Model\TaskModel;
-use Kanboard\Model\TaskCreationModel;
-use Kanboard\Model\TaskDuplicationModel;
-use Kanboard\Model\TaskFinderModel;
-use Kanboard\Model\ProjectModel;
-use Kanboard\Model\CategoryModel;
-use Kanboard\Model\TaskTagModel;
-
-class TaskDuplicationTest extends Base
-{
- public function testThatDuplicateDefineCreator()
- {
- $taskDuplicationModel = new TaskDuplicationModel($this->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);
- }
-}