summaryrefslogtreecommitdiff
path: root/tests/units
diff options
context:
space:
mode:
Diffstat (limited to 'tests/units')
-rw-r--r--tests/units/Export/TaskExportTest.php4
-rw-r--r--tests/units/Formatter/BoardFormatterTest.php44
-rw-r--r--tests/units/Job/TaskEventJobTest.php4
-rw-r--r--tests/units/Model/ProjectDuplicationModelTest.php68
-rw-r--r--tests/units/Model/SwimlaneModelTest.php328
-rw-r--r--tests/units/Model/SwimlaneTest.php370
-rw-r--r--tests/units/Model/TaskDuplicationModelTest.php2
-rw-r--r--tests/units/Model/TaskFinderModelTest.php5
-rw-r--r--tests/units/Model/TaskPositionModelTest.php42
-rw-r--r--tests/units/Model/TaskProjectDuplicationModelTest.php26
-rw-r--r--tests/units/Model/TaskProjectMoveModelTest.php20
-rw-r--r--tests/units/Model/TaskStatusModelTest.php143
-rw-r--r--tests/units/Model/TaskStatusTest.php143
-rw-r--r--tests/units/Validator/TaskValidatorTest.php11
14 files changed, 588 insertions, 622 deletions
diff --git a/tests/units/Export/TaskExportTest.php b/tests/units/Export/TaskExportTest.php
index ae6ca308..e8b347ac 100644
--- a/tests/units/Export/TaskExportTest.php
+++ b/tests/units/Export/TaskExportTest.php
@@ -19,7 +19,7 @@ class TaskExportTest extends Base
$swimlaneModel = new SwimlaneModel($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'Export Project')));
- $this->assertEquals(1, $swimlaneModel->create(array('project_id' => 1, 'name' => 'S1')));
+ $this->assertEquals(2, $swimlaneModel->create(1, 'S1'));
$this->assertEquals(1, $categoryModel->create(array('name' => 'Category #1', 'project_id' => 1)));
$this->assertEquals(1, $taskCreationModel->create(array(
@@ -34,7 +34,7 @@ class TaskExportTest extends Base
$this->assertEquals(2, $taskCreationModel->create(array(
'project_id' => 1,
- 'swimlane_id' => 1,
+ 'swimlane_id' => 2,
'title' => 'Task 2',
'date_due' => time(),
)));
diff --git a/tests/units/Formatter/BoardFormatterTest.php b/tests/units/Formatter/BoardFormatterTest.php
index 4d469eac..1b0ace1d 100644
--- a/tests/units/Formatter/BoardFormatterTest.php
+++ b/tests/units/Formatter/BoardFormatterTest.php
@@ -20,24 +20,24 @@ class BoardFormatterTest extends Base
$taskFinderModel = new TaskFinderModel($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'Test')));
- $this->assertEquals(1, $swimlaneModel->create(array('name' => 'Swimlane 1', 'project_id' => 1)));
- $this->assertEquals(2, $swimlaneModel->create(array('name' => 'Swimlane 2', 'project_id' => 1)));
+ $this->assertEquals(2, $swimlaneModel->create(1, 'Swimlane 1'));
+ $this->assertEquals(3, $swimlaneModel->create(1, 'Swimlane 2'));
// 2 task within the same column but no score
- $this->assertEquals(1, $taskCreationModel->create(array('title' => 'Task 1', 'project_id' => 1, 'swimlane_id' => 0, 'column_id' => 1)));
- $this->assertEquals(2, $taskCreationModel->create(array('title' => 'Task 2', 'project_id' => 1, 'swimlane_id' => 0, 'column_id' => 1)));
+ $this->assertEquals(1, $taskCreationModel->create(array('title' => 'Task 1', 'project_id' => 1, 'swimlane_id' => 1, 'column_id' => 1)));
+ $this->assertEquals(2, $taskCreationModel->create(array('title' => 'Task 2', 'project_id' => 1, 'swimlane_id' => 1, 'column_id' => 1)));
// 2 tasks in the same column with score
- $this->assertEquals(3, $taskCreationModel->create(array('title' => 'Task 3', 'project_id' => 1, 'swimlane_id' => 0, 'column_id' => 1, 'score' => 4)));
- $this->assertEquals(4, $taskCreationModel->create(array('title' => 'Task 4', 'project_id' => 1, 'swimlane_id' => 0, 'column_id' => 1, 'score' => 5)));
+ $this->assertEquals(3, $taskCreationModel->create(array('title' => 'Task 3', 'project_id' => 1, 'swimlane_id' => 1, 'column_id' => 1, 'score' => 4)));
+ $this->assertEquals(4, $taskCreationModel->create(array('title' => 'Task 4', 'project_id' => 1, 'swimlane_id' => 1, 'column_id' => 1, 'score' => 5)));
// 1 task in 2nd column
- $this->assertEquals(5, $taskCreationModel->create(array('title' => 'Task 5', 'project_id' => 1, 'swimlane_id' => 0, 'column_id' => 2)));
+ $this->assertEquals(5, $taskCreationModel->create(array('title' => 'Task 5', 'project_id' => 1, 'swimlane_id' => 1, 'column_id' => 2)));
// tasks in same column but different swimlanes
- $this->assertEquals(6, $taskCreationModel->create(array('title' => 'Task 6', 'project_id' => 1, 'swimlane_id' => 0, 'column_id' => 3, 'score' => 1)));
- $this->assertEquals(7, $taskCreationModel->create(array('title' => 'Task 7', 'project_id' => 1, 'swimlane_id' => 1, 'column_id' => 3, 'score' => 2)));
- $this->assertEquals(8, $taskCreationModel->create(array('title' => 'Task 8', 'project_id' => 1, 'swimlane_id' => 2, 'column_id' => 3, 'score' => 3)));
+ $this->assertEquals(6, $taskCreationModel->create(array('title' => 'Task 6', 'project_id' => 1, 'swimlane_id' => 1, 'column_id' => 3, 'score' => 1)));
+ $this->assertEquals(7, $taskCreationModel->create(array('title' => 'Task 7', 'project_id' => 1, 'swimlane_id' => 2, 'column_id' => 3, 'score' => 2)));
+ $this->assertEquals(8, $taskCreationModel->create(array('title' => 'Task 8', 'project_id' => 1, 'swimlane_id' => 3, 'column_id' => 3, 'score' => 3)));
$board = BoardFormatter::getInstance($this->container)
->withQuery($taskFinderModel->getExtendedQuery())
@@ -46,7 +46,7 @@ class BoardFormatterTest extends Base
$this->assertCount(3, $board);
- $this->assertSame(0, $board[0]['id']);
+ $this->assertSame(1, $board[0]['id']);
$this->assertEquals('Default swimlane', $board[0]['name']);
$this->assertCount(4, $board[0]['columns']);
$this->assertEquals(3, $board[0]['nb_swimlanes']);
@@ -85,7 +85,7 @@ class BoardFormatterTest extends Base
$this->assertEquals('Task 5', $board[0]['columns'][1]['tasks'][0]['title']);
$this->assertEquals('Task 6', $board[0]['columns'][2]['tasks'][0]['title']);
- $this->assertSame(1, $board[1]['id']);
+ $this->assertSame(2, $board[1]['id']);
$this->assertEquals('Swimlane 1', $board[1]['name']);
$this->assertCount(4, $board[1]['columns']);
$this->assertEquals(3, $board[1]['nb_swimlanes']);
@@ -134,14 +134,14 @@ class BoardFormatterTest extends Base
$taskFinderModel = new TaskFinderModel($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'Test')));
- $this->assertTrue($swimlaneModel->disableDefault(1));
- $this->assertEquals(1, $swimlaneModel->create(array('name' => 'Swimlane 1', 'project_id' => 1)));
- $this->assertEquals(2, $swimlaneModel->create(array('name' => 'Swimlane 2', 'project_id' => 1)));
+ $this->assertTrue($swimlaneModel->disable(1, 1));
+ $this->assertEquals(2, $swimlaneModel->create(1, 'Swimlane 1'));
+ $this->assertEquals(3, $swimlaneModel->create(1, 'Swimlane 2'));
- $this->assertEquals(1, $taskCreationModel->create(array('title' => 'Task 1', 'project_id' => 1, 'swimlane_id' => 1, 'column_id' => 1)));
- $this->assertEquals(2, $taskCreationModel->create(array('title' => 'Task 2', 'project_id' => 1, 'swimlane_id' => 2, 'column_id' => 2)));
- $this->assertEquals(3, $taskCreationModel->create(array('title' => 'Task 3', 'project_id' => 1, 'swimlane_id' => 1, 'column_id' => 2, 'score' => 1)));
- $this->assertEquals(4, $taskCreationModel->create(array('title' => 'Task 4', 'project_id' => 1, 'swimlane_id' => 2, 'column_id' => 1)));
+ $this->assertEquals(1, $taskCreationModel->create(array('title' => 'Task 1', 'project_id' => 1, 'swimlane_id' => 2, 'column_id' => 1)));
+ $this->assertEquals(2, $taskCreationModel->create(array('title' => 'Task 2', 'project_id' => 1, 'swimlane_id' => 3, 'column_id' => 2)));
+ $this->assertEquals(3, $taskCreationModel->create(array('title' => 'Task 3', 'project_id' => 1, 'swimlane_id' => 2, 'column_id' => 2, 'score' => 1)));
+ $this->assertEquals(4, $taskCreationModel->create(array('title' => 'Task 4', 'project_id' => 1, 'swimlane_id' => 3, 'column_id' => 1)));
$board = BoardFormatter::getInstance($this->container)
->withQuery($taskFinderModel->getExtendedQuery())
@@ -208,7 +208,7 @@ class BoardFormatterTest extends Base
$swimlaneModel = new SwimlaneModel($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'Test')));
- $this->assertTrue($swimlaneModel->disableDefault(1));
+ $this->assertTrue($swimlaneModel->disable(1, 1));
$board = BoardFormatter::getInstance($this->container)
->withQuery($taskFinderModel->getExtendedQuery())
@@ -245,8 +245,8 @@ class BoardFormatterTest extends Base
$taskFinderModel = new TaskFinderModel($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'Test')));
- $this->assertEquals(1, $swimlaneModel->create(array('name' => 'Swimlane 1', 'project_id' => 1)));
- $this->assertEquals(2, $swimlaneModel->create(array('name' => 'Swimlane 2', 'project_id' => 1)));
+ $this->assertEquals(2, $swimlaneModel->create(1, 'Swimlane 1'));
+ $this->assertEquals(3, $swimlaneModel->create(1, 'Swimlane 2'));
$board = BoardFormatter::getInstance($this->container)
->withQuery($taskFinderModel->getExtendedQuery())
diff --git a/tests/units/Job/TaskEventJobTest.php b/tests/units/Job/TaskEventJobTest.php
index bfd7bc55..d8c4bb8b 100644
--- a/tests/units/Job/TaskEventJobTest.php
+++ b/tests/units/Job/TaskEventJobTest.php
@@ -162,9 +162,9 @@ class TaskEventJobTest extends Base
$swimlaneModel = new SwimlaneModel($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
- $this->assertEquals(1, $swimlaneModel->create(array('name' => 'S1', 'project_id' => 1)));
+ $this->assertEquals(2, $swimlaneModel->create(1, 'S1'));
$this->assertEquals(1, $taskCreationModel->create(array('title' => 'test 1', 'project_id' => 1)));
- $this->assertTrue($taskPositionModel->movePosition(1, 1, 1, 1, 1));
+ $this->assertTrue($taskPositionModel->movePosition(1, 1, 1, 1, 2));
$called = $this->container['dispatcher']->getCalledListeners();
$this->assertArrayHasKey(TaskModel::EVENT_MOVE_SWIMLANE.'.closure', $called);
diff --git a/tests/units/Model/ProjectDuplicationModelTest.php b/tests/units/Model/ProjectDuplicationModelTest.php
index 54261728..8b505d2b 100644
--- a/tests/units/Model/ProjectDuplicationModelTest.php
+++ b/tests/units/Model/ProjectDuplicationModelTest.php
@@ -24,8 +24,8 @@ class ProjectDuplicationModelTest extends Base
public function testGetSelections()
{
$projectDuplicationModel = new ProjectDuplicationModel($this->container);
- $this->assertCount(7, $projectDuplicationModel->getOptionalSelection());
- $this->assertCount(8, $projectDuplicationModel->getPossibleSelection());
+ $this->assertCount(6, $projectDuplicationModel->getOptionalSelection());
+ $this->assertCount(9, $projectDuplicationModel->getPossibleSelection());
}
public function testGetClonedProjectName()
@@ -405,32 +405,31 @@ class ProjectDuplicationModelTest extends Base
$taskCreationModel = new TaskCreationModel($this->container);
$taskFinderModel = new TaskFinderModel($this->container);
- $this->assertEquals(1, $projectModel->create(array('name' => 'P1', 'default_swimlane' => 'New Default')));
+ $this->assertEquals(1, $projectModel->create(array('name' => 'P1')));
// create initial swimlanes
- $this->assertEquals(1, $swimlaneModel->create(array('project_id' => 1, 'name' => 'S1')));
- $this->assertEquals(2, $swimlaneModel->create(array('project_id' => 1, 'name' => 'S2')));
- $this->assertEquals(3, $swimlaneModel->create(array('project_id' => 1, 'name' => 'S3')));
+ $this->assertEquals(2, $swimlaneModel->create(1, 'S1'));
+ $this->assertEquals(3, $swimlaneModel->create(1, 'S2'));
+ $this->assertEquals(4, $swimlaneModel->create(1, 'S3'));
// create initial tasks
- $this->assertEquals(1, $taskCreationModel->create(array('title' => 'T0', 'project_id' => 1, 'swimlane_id' => 0)));
- $this->assertEquals(2, $taskCreationModel->create(array('title' => 'T1', 'project_id' => 1, 'swimlane_id' => 1)));
- $this->assertEquals(3, $taskCreationModel->create(array('title' => 'T2', 'project_id' => 1, 'swimlane_id' => 2)));
- $this->assertEquals(4, $taskCreationModel->create(array('title' => 'T3', 'project_id' => 1, 'swimlane_id' => 3)));
+ $this->assertEquals(1, $taskCreationModel->create(array('title' => 'T0', 'project_id' => 1, 'swimlane_id' => 1)));
+ $this->assertEquals(2, $taskCreationModel->create(array('title' => 'T1', 'project_id' => 1, 'swimlane_id' => 2)));
+ $this->assertEquals(3, $taskCreationModel->create(array('title' => 'T2', 'project_id' => 1, 'swimlane_id' => 3)));
+ $this->assertEquals(4, $taskCreationModel->create(array('title' => 'T3', 'project_id' => 1, 'swimlane_id' => 4)));
$this->assertEquals(2, $projectDuplicationModel->duplicate(1, array('categoryModel', 'swimlaneModel')));
$swimlanes = $swimlaneModel->getAll(2);
- $this->assertCount(3, $swimlanes);
- $this->assertEquals(4, $swimlanes[0]['id']);
- $this->assertEquals('S1', $swimlanes[0]['name']);
- $this->assertEquals(5, $swimlanes[1]['id']);
- $this->assertEquals('S2', $swimlanes[1]['name']);
- $this->assertEquals(6, $swimlanes[2]['id']);
- $this->assertEquals('S3', $swimlanes[2]['name']);
-
- $swimlane = $swimlaneModel->getDefault(2);
- $this->assertEquals('New Default', $swimlane['default_swimlane']);
+ $this->assertCount(4, $swimlanes);
+ $this->assertEquals(5, $swimlanes[0]['id']);
+ $this->assertEquals('Default swimlane', $swimlanes[0]['name']);
+ $this->assertEquals(6, $swimlanes[1]['id']);
+ $this->assertEquals('S1', $swimlanes[1]['name']);
+ $this->assertEquals(7, $swimlanes[2]['id']);
+ $this->assertEquals('S2', $swimlanes[2]['name']);
+ $this->assertEquals(8, $swimlanes[3]['id']);
+ $this->assertEquals('S3', $swimlanes[3]['name']);
// Check if tasks are NOT been duplicated
$this->assertCount(0, $taskFinderModel->getAll(2));
@@ -445,7 +444,7 @@ class ProjectDuplicationModelTest extends Base
$this->assertEquals(1, $projectModel->create(array('name' => 'P1')));
- // create initial tasks
+ // Create initial tasks
$this->assertEquals(1, $taskCreationModel->create(array('title' => 'T1', 'project_id' => 1, 'column_id' => 1)));
$this->assertEquals(2, $taskCreationModel->create(array('title' => 'T2', 'project_id' => 1, 'column_id' => 2)));
$this->assertEquals(3, $taskCreationModel->create(array('title' => 'T3', 'project_id' => 1, 'column_id' => 3)));
@@ -468,12 +467,12 @@ class ProjectDuplicationModelTest extends Base
$taskCreationModel = new TaskCreationModel($this->container);
$taskFinderModel = new TaskFinderModel($this->container);
- $this->assertEquals(1, $projectModel->create(array('name' => 'P1', 'default_swimlane' => 'New Default')));
+ $this->assertEquals(1, $projectModel->create(array('name' => 'P1')));
// create initial swimlanes
- $this->assertEquals(1, $swimlaneModel->create(array('project_id' => 1, 'name' => 'S1')));
- $this->assertEquals(2, $swimlaneModel->create(array('project_id' => 1, 'name' => 'S2')));
- $this->assertEquals(3, $swimlaneModel->create(array('project_id' => 1, 'name' => 'S3')));
+ $this->assertEquals(2, $swimlaneModel->create(1, 'S1'));
+ $this->assertEquals(3, $swimlaneModel->create(1, 'S2'));
+ $this->assertEquals(4, $swimlaneModel->create(1, 'S3'));
// create initial tasks
$this->assertEquals(1, $taskCreationModel->create(array('title' => 'T1', 'project_id' => 1, 'column_id' => 1, 'owner_id' => 1)));
@@ -484,16 +483,15 @@ class ProjectDuplicationModelTest extends Base
// Check if Swimlanes have been duplicated
$swimlanes = $swimlaneModel->getAll(2);
- $this->assertCount(3, $swimlanes);
- $this->assertEquals(4, $swimlanes[0]['id']);
- $this->assertEquals('S1', $swimlanes[0]['name']);
- $this->assertEquals(5, $swimlanes[1]['id']);
- $this->assertEquals('S2', $swimlanes[1]['name']);
- $this->assertEquals(6, $swimlanes[2]['id']);
- $this->assertEquals('S3', $swimlanes[2]['name']);
-
- $swimlane = $swimlaneModel->getDefault(2);
- $this->assertEquals('New Default', $swimlane['default_swimlane']);
+ $this->assertCount(4, $swimlanes);
+ $this->assertEquals(5, $swimlanes[0]['id']);
+ $this->assertEquals('Default swimlane', $swimlanes[0]['name']);
+ $this->assertEquals(6, $swimlanes[1]['id']);
+ $this->assertEquals('S1', $swimlanes[1]['name']);
+ $this->assertEquals(7, $swimlanes[2]['id']);
+ $this->assertEquals('S2', $swimlanes[2]['name']);
+ $this->assertEquals(8, $swimlanes[3]['id']);
+ $this->assertEquals('S3', $swimlanes[3]['name']);
// Check if Tasks have been duplicated
$tasks = $taskFinderModel->getAll(2);
diff --git a/tests/units/Model/SwimlaneModelTest.php b/tests/units/Model/SwimlaneModelTest.php
new file mode 100644
index 00000000..73cc9e09
--- /dev/null
+++ b/tests/units/Model/SwimlaneModelTest.php
@@ -0,0 +1,328 @@
+<?php
+
+require_once __DIR__.'/../Base.php';
+
+use Kanboard\Model\ProjectModel;
+use Kanboard\Model\TaskCreationModel;
+use Kanboard\Model\TaskFinderModel;
+use Kanboard\Model\SwimlaneModel;
+
+class SwimlaneModelTest extends Base
+{
+ public function testCreation()
+ {
+ $projectModel = new ProjectModel($this->container);
+ $swimlaneModel = new SwimlaneModel($this->container);
+
+ $this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest')));
+ $this->assertEquals(2, $swimlaneModel->create(1, 'Swimlane #1'));
+
+ $swimlanes = $swimlaneModel->getAll(1);
+ $this->assertNotEmpty($swimlanes);
+ $this->assertEquals(2, count($swimlanes));
+ $this->assertEquals('Default swimlane', $swimlanes[0]['name']);
+ $this->assertEquals('Swimlane #1', $swimlanes[1]['name']);
+
+ $this->assertEquals(2, $swimlaneModel->getIdByName(1, 'Swimlane #1'));
+ $this->assertEquals(0, $swimlaneModel->getIdByName(2, 'Swimlane #2'));
+
+ $this->assertEquals('Default swimlane', $swimlaneModel->getNameById(1));
+ $this->assertEquals('Swimlane #1', $swimlaneModel->getNameById(2));
+ $this->assertEquals('', $swimlaneModel->getNameById(23));
+ }
+
+ public function testGetFirstActiveSwimlane()
+ {
+ $projectModel = new ProjectModel($this->container);
+ $swimlaneModel = new SwimlaneModel($this->container);
+
+ $this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest')));
+ $this->assertEquals(2, $swimlaneModel->create(1, 'Swimlane #1'));
+ $this->assertEquals(3, $swimlaneModel->create(1, 'Swimlane #2'));
+
+ $this->assertTrue($swimlaneModel->disable(1, 2));
+
+ $swimlane = $swimlaneModel->getFirstActiveSwimlane(1);
+ $this->assertEquals(1, $swimlane['id']);
+ $this->assertEquals('Default swimlane', $swimlane['name']);
+ $this->assertSame(1, $swimlaneModel->getFirstActiveSwimlaneId(1));
+
+ $this->assertTrue($swimlaneModel->disable(1, 1));
+
+ $swimlane = $swimlaneModel->getFirstActiveSwimlane(1);
+ $this->assertEquals(3, $swimlane['id']);
+ $this->assertEquals('Swimlane #2', $swimlane['name']);
+ $this->assertSame(3, $swimlaneModel->getFirstActiveSwimlaneId(1));
+
+ $this->assertTrue($swimlaneModel->disable(1, 3));
+ $this->assertNull($swimlaneModel->getFirstActiveSwimlane(1));
+ $this->assertSame(0, $swimlaneModel->getFirstActiveSwimlaneId(1));
+ }
+
+ public function testGetList()
+ {
+ $projectModel = new ProjectModel($this->container);
+ $swimlaneModel = new SwimlaneModel($this->container);
+
+ $this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest')));
+ $this->assertEquals(2, $swimlaneModel->create(1, 'Swimlane #1'));
+ $this->assertEquals(3, $swimlaneModel->create(1, 'Swimlane #2'));
+
+ $swimlanes = $swimlaneModel->getList(1);
+ $expected = array(
+ 1 => 'Default swimlane',
+ 2 => 'Swimlane #1',
+ 3 => 'Swimlane #2',
+ );
+
+ $this->assertEquals($expected, $swimlanes);
+ }
+
+ public function testUpdate()
+ {
+ $projectModel = new ProjectModel($this->container);
+ $swimlaneModel = new SwimlaneModel($this->container);
+
+ $this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest')));
+ $this->assertEquals(2, $swimlaneModel->create(1, 'Swimlane #1'));
+
+ $this->assertTrue($swimlaneModel->update(array('id' => 2, 'name' => 'foobar')));
+
+ $swimlane = $swimlaneModel->getById(2);
+ $this->assertEquals('foobar', $swimlane['name']);
+ }
+
+ public function testDisableEnable()
+ {
+ $projectModel = new ProjectModel($this->container);
+ $swimlaneModel = new SwimlaneModel($this->container);
+
+ $this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest')));
+ $this->assertEquals(2, $swimlaneModel->create(1, 'Swimlane #1'));
+
+ $swimlane = $swimlaneModel->getById(1);
+ $this->assertNotEmpty($swimlane);
+ $this->assertEquals(1, $swimlane['is_active']);
+ $this->assertEquals(1, $swimlane['position']);
+
+ $this->assertEquals(3, $swimlaneModel->getLastPosition(1));
+ $this->assertTrue($swimlaneModel->disable(1, 1));
+
+ $swimlane = $swimlaneModel->getById(1);
+ $this->assertNotEmpty($swimlane);
+ $this->assertEquals(0, $swimlane['is_active']);
+ $this->assertEquals(0, $swimlane['position']);
+
+ $this->assertEquals(2, $swimlaneModel->getLastPosition(1));
+
+ // Create a new swimlane
+ $this->assertEquals(3, $swimlaneModel->create(1, 'Swimlane #2'));
+
+ $swimlane = $swimlaneModel->getById(2);
+ $this->assertNotEmpty($swimlane);
+ $this->assertEquals(1, $swimlane['is_active']);
+ $this->assertEquals(1, $swimlane['position']);
+
+ // Enable our disabled swimlane
+ $this->assertTrue($swimlaneModel->enable(1, 1));
+
+ $swimlane = $swimlaneModel->getById(1);
+ $this->assertNotEmpty($swimlane);
+ $this->assertEquals(1, $swimlane['is_active']);
+ $this->assertEquals(3, $swimlane['position']);
+ }
+
+ public function testRemove()
+ {
+ $projectModel = new ProjectModel($this->container);
+ $swimlaneModel = new SwimlaneModel($this->container);
+ $taskCreationModel = new TaskCreationModel($this->container);
+
+ $this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest')));
+ $this->assertEquals(2, $swimlaneModel->create(1, 'Swimlane #1'));
+ $this->assertEquals(1, $taskCreationModel->create(array('title' => 'test', 'project_id' => 1, 'swimlane_id' => 2)));
+
+ $this->assertFalse($swimlaneModel->remove(1, 2));
+ $this->assertTrue($swimlaneModel->remove(1, 1));
+
+ $this->assertEmpty($swimlaneModel->getById(1));
+ }
+
+ public function testUpdatePositions()
+ {
+ $projectModel = new ProjectModel($this->container);
+ $swimlaneModel = new SwimlaneModel($this->container);
+
+ $this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest')));
+ $this->assertEquals(2, $swimlaneModel->create(1, 'Swimlane #1'));
+ $this->assertEquals(3, $swimlaneModel->create(1, 'Swimlane #2'));
+ $this->assertEquals(4, $swimlaneModel->create(1, 'Swimlane #3'));
+
+ $swimlane = $swimlaneModel->getById(1);
+ $this->assertNotEmpty($swimlane);
+ $this->assertEquals(1, $swimlane['is_active']);
+ $this->assertEquals(1, $swimlane['position']);
+
+ $swimlane = $swimlaneModel->getById(2);
+ $this->assertNotEmpty($swimlane);
+ $this->assertEquals(1, $swimlane['is_active']);
+ $this->assertEquals(2, $swimlane['position']);
+
+ $swimlane = $swimlaneModel->getById(3);
+ $this->assertNotEmpty($swimlane);
+ $this->assertEquals(1, $swimlane['is_active']);
+ $this->assertEquals(3, $swimlane['position']);
+
+ // Disable the 2nd swimlane
+ $this->assertTrue($swimlaneModel->disable(1, 2));
+
+ $swimlane = $swimlaneModel->getById(1);
+ $this->assertNotEmpty($swimlane);
+ $this->assertEquals(1, $swimlane['is_active']);
+ $this->assertEquals(1, $swimlane['position']);
+
+ $swimlane = $swimlaneModel->getById(2);
+ $this->assertNotEmpty($swimlane);
+ $this->assertEquals(0, $swimlane['is_active']);
+ $this->assertEquals(0, $swimlane['position']);
+
+ $swimlane = $swimlaneModel->getById(3);
+ $this->assertNotEmpty($swimlane);
+ $this->assertEquals(1, $swimlane['is_active']);
+ $this->assertEquals(2, $swimlane['position']);
+
+ // Remove the first swimlane
+ $this->assertTrue($swimlaneModel->remove(1, 1));
+
+ $swimlane = $swimlaneModel->getById(1);
+ $this->assertEmpty($swimlane);
+
+ $swimlane = $swimlaneModel->getById(2);
+ $this->assertNotEmpty($swimlane);
+ $this->assertEquals(0, $swimlane['is_active']);
+ $this->assertEquals(0, $swimlane['position']);
+
+ $swimlane = $swimlaneModel->getById(3);
+ $this->assertNotEmpty($swimlane);
+ $this->assertEquals(1, $swimlane['is_active']);
+ $this->assertEquals(1, $swimlane['position']);
+ }
+
+ public function testDuplicateSwimlane()
+ {
+ $projectModel = new ProjectModel($this->container);
+ $swimlaneModel = new SwimlaneModel($this->container);
+
+ $this->assertEquals(1, $projectModel->create(array('name' => 'P1')));
+ $this->assertEquals(2, $projectModel->create(array('name' => 'P2')));
+ $this->assertEquals(3, $swimlaneModel->create(1, 'S1'));
+ $this->assertEquals(4, $swimlaneModel->create(1, 'S2'));
+ $this->assertEquals(5, $swimlaneModel->create(1, 'S3'));
+
+ $this->assertTrue($swimlaneModel->duplicate(1, 2));
+
+ $swimlanes = $swimlaneModel->getAll(2);
+
+ $this->assertCount(4, $swimlanes);
+ $this->assertEquals(2, $swimlanes[0]['id']);
+ $this->assertEquals('Default swimlane', $swimlanes[0]['name']);
+ $this->assertEquals(6, $swimlanes[1]['id']);
+ $this->assertEquals('S1', $swimlanes[1]['name']);
+ $this->assertEquals(7, $swimlanes[2]['id']);
+ $this->assertEquals('S2', $swimlanes[2]['name']);
+ $this->assertEquals(8, $swimlanes[3]['id']);
+ $this->assertEquals('S3', $swimlanes[3]['name']);
+ }
+
+ public function testChangePosition()
+ {
+ $projectModel = new ProjectModel($this->container);
+ $swimlaneModel = new SwimlaneModel($this->container);
+
+ $this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
+ $this->assertEquals(2, $swimlaneModel->create(1, 'Swimlane #1'));
+ $this->assertEquals(3, $swimlaneModel->create(1, 'Swimlane #2'));
+ $this->assertEquals(4, $swimlaneModel->create(1, 'Swimlane #3'));
+ $this->assertEquals(5, $swimlaneModel->create(1, 'Swimlane #4'));
+
+ $swimlanes = $swimlaneModel->getAllByStatus(1);
+ $this->assertEquals(1, $swimlanes[0]['position']);
+ $this->assertEquals(1, $swimlanes[0]['id']);
+ $this->assertEquals(2, $swimlanes[1]['position']);
+ $this->assertEquals(2, $swimlanes[1]['id']);
+ $this->assertEquals(3, $swimlanes[2]['position']);
+ $this->assertEquals(3, $swimlanes[2]['id']);
+
+ $this->assertTrue($swimlaneModel->changePosition(1, 3, 2));
+
+ $swimlanes = $swimlaneModel->getAllByStatus(1);
+ $this->assertEquals(1, $swimlanes[0]['position']);
+ $this->assertEquals(1, $swimlanes[0]['id']);
+ $this->assertEquals(2, $swimlanes[1]['position']);
+ $this->assertEquals(3, $swimlanes[1]['id']);
+ $this->assertEquals(3, $swimlanes[2]['position']);
+ $this->assertEquals(2, $swimlanes[2]['id']);
+
+ $this->assertTrue($swimlaneModel->changePosition(1, 2, 1));
+
+ $swimlanes = $swimlaneModel->getAllByStatus(1);
+ $this->assertEquals(1, $swimlanes[0]['position']);
+ $this->assertEquals(2, $swimlanes[0]['id']);
+ $this->assertEquals(2, $swimlanes[1]['position']);
+ $this->assertEquals(1, $swimlanes[1]['id']);
+ $this->assertEquals(3, $swimlanes[2]['position']);
+ $this->assertEquals(3, $swimlanes[2]['id']);
+
+ $this->assertTrue($swimlaneModel->changePosition(1, 2, 2));
+
+ $swimlanes = $swimlaneModel->getAllByStatus(1);
+ $this->assertEquals(1, $swimlanes[0]['position']);
+ $this->assertEquals(1, $swimlanes[0]['id']);
+ $this->assertEquals(2, $swimlanes[1]['position']);
+ $this->assertEquals(2, $swimlanes[1]['id']);
+ $this->assertEquals(3, $swimlanes[2]['position']);
+ $this->assertEquals(3, $swimlanes[2]['id']);
+
+ $this->assertTrue($swimlaneModel->changePosition(1, 4, 1));
+
+ $swimlanes = $swimlaneModel->getAllByStatus(1);
+ $this->assertEquals(1, $swimlanes[0]['position']);
+ $this->assertEquals(4, $swimlanes[0]['id']);
+ $this->assertEquals(2, $swimlanes[1]['position']);
+ $this->assertEquals(1, $swimlanes[1]['id']);
+ $this->assertEquals(3, $swimlanes[2]['position']);
+ $this->assertEquals(2, $swimlanes[2]['id']);
+
+ $this->assertFalse($swimlaneModel->changePosition(1, 2, 0));
+ $this->assertFalse($swimlaneModel->changePosition(1, 2, 8));
+ }
+
+ public function testChangePositionWithInactiveSwimlane()
+ {
+ $projectModel = new ProjectModel($this->container);
+ $swimlaneModel = new SwimlaneModel($this->container);
+
+ $this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
+ $this->assertEquals(2, $swimlaneModel->create(1, 'Swimlane #1'));
+ $this->assertEquals(3, $swimlaneModel->create(1, 'Swimlane #2'));
+ $this->assertEquals(4, $swimlaneModel->create(1, 'Swimlane #3'));
+ $this->assertEquals(5, $swimlaneModel->create(1, 'Swimlane #4'));
+
+ $this->assertTrue($swimlaneModel->disable(1, 2));
+ $this->assertTrue($swimlaneModel->disable(1, 3));
+
+ $swimlanes = $swimlaneModel->getAllByStatus(1);
+ $this->assertEquals(1, $swimlanes[0]['position']);
+ $this->assertEquals(1, $swimlanes[0]['id']);
+ $this->assertEquals(2, $swimlanes[1]['position']);
+ $this->assertEquals(4, $swimlanes[1]['id']);
+
+ $this->assertTrue($swimlaneModel->changePosition(1, 4, 1));
+
+ $swimlanes = $swimlaneModel->getAllByStatus(1);
+ $this->assertEquals(1, $swimlanes[0]['position']);
+ $this->assertEquals(4, $swimlanes[0]['id']);
+ $this->assertEquals(2, $swimlanes[1]['position']);
+ $this->assertEquals(1, $swimlanes[1]['id']);
+ }
+}
diff --git a/tests/units/Model/SwimlaneTest.php b/tests/units/Model/SwimlaneTest.php
deleted file mode 100644
index 4541e07f..00000000
--- a/tests/units/Model/SwimlaneTest.php
+++ /dev/null
@@ -1,370 +0,0 @@
-<?php
-
-require_once __DIR__.'/../Base.php';
-
-use Kanboard\Model\ProjectModel;
-use Kanboard\Model\TaskCreationModel;
-use Kanboard\Model\TaskFinderModel;
-use Kanboard\Model\SwimlaneModel;
-
-class SwimlaneTest extends Base
-{
- public function testCreation()
- {
- $p = new ProjectModel($this->container);
- $s = new SwimlaneModel($this->container);
-
- $this->assertEquals(1, $p->create(array('name' => 'UnitTest')));
- $this->assertEquals(1, $s->create(array('project_id' => 1, 'name' => 'Swimlane #1')));
-
- $swimlanes = $s->getSwimlanes(1);
- $this->assertNotEmpty($swimlanes);
- $this->assertEquals(2, count($swimlanes));
- $this->assertEquals('Default swimlane', $swimlanes[0]['name']);
- $this->assertEquals('Swimlane #1', $swimlanes[1]['name']);
-
- $this->assertEquals(1, $s->getIdByName(1, 'Swimlane #1'));
- $this->assertEquals(0, $s->getIdByName(2, 'Swimlane #2'));
-
- $this->assertEquals('Swimlane #1', $s->getNameById(1));
- $this->assertEquals('', $s->getNameById(23));
- }
-
- public function testGetFirstActiveSwimlane()
- {
- $projectModel = new ProjectModel($this->container);
- $swimlaneModel = new SwimlaneModel($this->container);
-
- $this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest')));
- $this->assertEquals(1, $swimlaneModel->create(array('project_id' => 1, 'name' => 'Swimlane #1', 'is_active' => 0)));
- $this->assertEquals(2, $swimlaneModel->create(array('project_id' => 1, 'name' => 'Swimlane #2')));
-
- $swimlane = $swimlaneModel->getFirstActiveSwimlane(1);
- $this->assertEquals(0, $swimlane['id']);
- $this->assertEquals('Default swimlane', $swimlane['name']);
-
- $this->assertTrue($swimlaneModel->disableDefault(1));
-
- $swimlane = $swimlaneModel->getFirstActiveSwimlane(1);
- $this->assertEquals(2, $swimlane['id']);
- $this->assertEquals('Swimlane #2', $swimlane['name']);
-
- $this->assertTrue($swimlaneModel->disable(1, 2));
- $this->assertNull($swimlaneModel->getFirstActiveSwimlane(1));
- }
-
- public function testGetList()
- {
- $p = new ProjectModel($this->container);
- $s = new SwimlaneModel($this->container);
-
- $this->assertEquals(1, $p->create(array('name' => 'UnitTest')));
- $this->assertEquals(1, $s->create(array('project_id' => 1, 'name' => 'Swimlane #1')));
- $this->assertEquals(2, $s->create(array('project_id' => 1, 'name' => 'Swimlane #2')));
-
- $swimlanes = $s->getList(1);
- $expected = array('Default swimlane', 'Swimlane #1', 'Swimlane #2');
-
- $this->assertEquals($expected, $swimlanes);
- }
-
- public function testUpdate()
- {
- $p = new ProjectModel($this->container);
- $s = new SwimlaneModel($this->container);
-
- $this->assertEquals(1, $p->create(array('name' => 'UnitTest')));
- $this->assertEquals(1, $s->create(array('project_id' => 1, 'name' => 'Swimlane #1')));
-
- $swimlane = $s->getById(1);
- $this->assertNotEmpty($swimlane);
- $this->assertEquals('Swimlane #1', $swimlane['name']);
-
- $this->assertTrue($s->update(array('id' => 1, 'name' => 'foobar')));
-
- $swimlane = $s->getById(1);
- $this->assertNotEmpty($swimlane);
- $this->assertEquals('foobar', $swimlane['name']);
- }
-
- public function testUpdateDefaultSwimlane()
- {
- $p = new ProjectModel($this->container);
- $s = new SwimlaneModel($this->container);
-
- $this->assertEquals(1, $p->create(array('name' => 'UnitTest')));
- $this->assertTrue($s->updateDefault(array('id' => 1, 'default_swimlane' => 'foo', 'show_default_swimlane' => 1)));
-
- $default = $s->getDefault(1);
- $this->assertNotEmpty($default);
- $this->assertEquals('foo', $default['default_swimlane']);
- $this->assertEquals(1, $default['show_default_swimlane']);
-
- $this->assertTrue($s->updateDefault(array('id' => 1, 'default_swimlane' => 'foo', 'show_default_swimlane' => 0)));
-
- $default = $s->getDefault(1);
- $this->assertNotEmpty($default);
- $this->assertEquals('foo', $default['default_swimlane']);
- $this->assertEquals(0, $default['show_default_swimlane']);
- }
-
- public function testDisableEnableDefaultSwimlane()
- {
- $projectModel = new ProjectModel($this->container);
- $swimlaneModel = new SwimlaneModel($this->container);
-
- $this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest')));
-
- $this->assertTrue($swimlaneModel->disableDefault(1));
- $default = $swimlaneModel->getDefault(1);
- $this->assertEquals(0, $default['show_default_swimlane']);
-
- $this->assertTrue($swimlaneModel->enableDefault(1));
- $default = $swimlaneModel->getDefault(1);
- $this->assertEquals(1, $default['show_default_swimlane']);
- }
-
- public function testDisableEnable()
- {
- $p = new ProjectModel($this->container);
- $s = new SwimlaneModel($this->container);
-
- $this->assertEquals(1, $p->create(array('name' => 'UnitTest')));
- $this->assertEquals(1, $s->create(array('project_id' => 1, 'name' => 'Swimlane #1')));
-
- $swimlane = $s->getById(1);
- $this->assertNotEmpty($swimlane);
- $this->assertEquals(1, $swimlane['is_active']);
- $this->assertEquals(1, $swimlane['position']);
-
- $this->assertEquals(2, $s->getLastPosition(1));
- $this->assertTrue($s->disable(1, 1));
-
- $swimlane = $s->getById(1);
- $this->assertNotEmpty($swimlane);
- $this->assertEquals(0, $swimlane['is_active']);
- $this->assertEquals(0, $swimlane['position']);
-
- $this->assertEquals(1, $s->getLastPosition(1));
-
- // Create a new swimlane
- $this->assertEquals(2, $s->create(array('project_id' => 1, 'name' => 'Swimlane #2')));
-
- $swimlane = $s->getById(2);
- $this->assertNotEmpty($swimlane);
- $this->assertEquals(1, $swimlane['is_active']);
- $this->assertEquals(1, $swimlane['position']);
-
- // Enable our disabled swimlane
- $this->assertTrue($s->enable(1, 1));
-
- $swimlane = $s->getById(1);
- $this->assertNotEmpty($swimlane);
- $this->assertEquals(1, $swimlane['is_active']);
- $this->assertEquals(2, $swimlane['position']);
- }
-
- public function testRemove()
- {
- $p = new ProjectModel($this->container);
- $s = new SwimlaneModel($this->container);
- $tc = new TaskCreationModel($this->container);
- $tf = new TaskFinderModel($this->container);
-
- $this->assertEquals(1, $p->create(array('name' => 'UnitTest')));
- $this->assertEquals(1, $s->create(array('project_id' => 1, 'name' => 'Swimlane #1')));
- $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'swimlane_id' => 1)));
-
- $task = $tf->getById(1);
- $this->assertNotEmpty($task);
- $this->assertEquals(1, $task['swimlane_id']);
-
- $this->assertTrue($s->remove(1, 1));
-
- $task = $tf->getById(1);
- $this->assertNotEmpty($task);
- $this->assertEquals(0, $task['swimlane_id']);
-
- $this->assertEmpty($s->getById(1));
- }
-
- public function testUpdatePositions()
- {
- $p = new ProjectModel($this->container);
- $s = new SwimlaneModel($this->container);
-
- $this->assertEquals(1, $p->create(array('name' => 'UnitTest')));
- $this->assertEquals(1, $s->create(array('project_id' => 1, 'name' => 'Swimlane #1')));
- $this->assertEquals(2, $s->create(array('project_id' => 1, 'name' => 'Swimlane #2')));
- $this->assertEquals(3, $s->create(array('project_id' => 1, 'name' => 'Swimlane #3')));
-
- $swimlane = $s->getById(1);
- $this->assertNotEmpty($swimlane);
- $this->assertEquals(1, $swimlane['is_active']);
- $this->assertEquals(1, $swimlane['position']);
-
- $swimlane = $s->getById(2);
- $this->assertNotEmpty($swimlane);
- $this->assertEquals(1, $swimlane['is_active']);
- $this->assertEquals(2, $swimlane['position']);
-
- $swimlane = $s->getById(3);
- $this->assertNotEmpty($swimlane);
- $this->assertEquals(1, $swimlane['is_active']);
- $this->assertEquals(3, $swimlane['position']);
-
- // Disable the 2nd swimlane
- $this->assertTrue($s->disable(1, 2));
-
- $swimlane = $s->getById(1);
- $this->assertNotEmpty($swimlane);
- $this->assertEquals(1, $swimlane['is_active']);
- $this->assertEquals(1, $swimlane['position']);
-
- $swimlane = $s->getById(2);
- $this->assertNotEmpty($swimlane);
- $this->assertEquals(0, $swimlane['is_active']);
- $this->assertEquals(0, $swimlane['position']);
-
- $swimlane = $s->getById(3);
- $this->assertNotEmpty($swimlane);
- $this->assertEquals(1, $swimlane['is_active']);
- $this->assertEquals(2, $swimlane['position']);
-
- // Remove the first swimlane
- $this->assertTrue($s->remove(1, 1));
-
- $swimlane = $s->getById(1);
- $this->assertEmpty($swimlane);
-
- $swimlane = $s->getById(2);
- $this->assertNotEmpty($swimlane);
- $this->assertEquals(0, $swimlane['is_active']);
- $this->assertEquals(0, $swimlane['position']);
-
- $swimlane = $s->getById(3);
- $this->assertNotEmpty($swimlane);
- $this->assertEquals(1, $swimlane['is_active']);
- $this->assertEquals(1, $swimlane['position']);
- }
-
- public function testDuplicateSwimlane()
- {
- $p = new ProjectModel($this->container);
- $s = new SwimlaneModel($this->container);
-
- $this->assertEquals(1, $p->create(array('name' => 'P1')));
- $this->assertEquals(2, $p->create(array('name' => 'P2')));
- $this->assertEquals(1, $s->create(array('project_id' => 1, 'name' => 'S1')));
- $this->assertEquals(2, $s->create(array('project_id' => 1, 'name' => 'S2')));
- $this->assertEquals(3, $s->create(array('project_id' => 1, 'name' => 'S3')));
-
- $default_swimlane1 = $s->getDefault(1);
- $default_swimlane1['default_swimlane'] = 'New Default';
-
- $this->assertTrue($s->updateDefault($default_swimlane1));
-
- $this->assertTrue($s->duplicate(1, 2));
-
- $swimlanes = $s->getAll(2);
-
- $this->assertCount(3, $swimlanes);
- $this->assertEquals(4, $swimlanes[0]['id']);
- $this->assertEquals('S1', $swimlanes[0]['name']);
- $this->assertEquals(5, $swimlanes[1]['id']);
- $this->assertEquals('S2', $swimlanes[1]['name']);
- $this->assertEquals(6, $swimlanes[2]['id']);
- $this->assertEquals('S3', $swimlanes[2]['name']);
- $new_default = $s->getDefault(2);
- $this->assertEquals('New Default', $new_default['default_swimlane']);
- }
-
- public function testChangePosition()
- {
- $projectModel = new ProjectModel($this->container);
- $swimlaneModel = new SwimlaneModel($this->container);
-
- $this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
- $this->assertEquals(1, $swimlaneModel->create(array('project_id' => 1, 'name' => 'Swimlane #1')));
- $this->assertEquals(2, $swimlaneModel->create(array('project_id' => 1, 'name' => 'Swimlane #2')));
- $this->assertEquals(3, $swimlaneModel->create(array('project_id' => 1, 'name' => 'Swimlane #3')));
- $this->assertEquals(4, $swimlaneModel->create(array('project_id' => 1, 'name' => 'Swimlane #4')));
-
- $swimlanes = $swimlaneModel->getAllByStatus(1);
- $this->assertEquals(1, $swimlanes[0]['position']);
- $this->assertEquals(1, $swimlanes[0]['id']);
- $this->assertEquals(2, $swimlanes[1]['position']);
- $this->assertEquals(2, $swimlanes[1]['id']);
- $this->assertEquals(3, $swimlanes[2]['position']);
- $this->assertEquals(3, $swimlanes[2]['id']);
-
- $this->assertTrue($swimlaneModel->changePosition(1, 3, 2));
-
- $swimlanes = $swimlaneModel->getAllByStatus(1);
- $this->assertEquals(1, $swimlanes[0]['position']);
- $this->assertEquals(1, $swimlanes[0]['id']);
- $this->assertEquals(2, $swimlanes[1]['position']);
- $this->assertEquals(3, $swimlanes[1]['id']);
- $this->assertEquals(3, $swimlanes[2]['position']);
- $this->assertEquals(2, $swimlanes[2]['id']);
-
- $this->assertTrue($swimlaneModel->changePosition(1, 2, 1));
-
- $swimlanes = $swimlaneModel->getAllByStatus(1);
- $this->assertEquals(1, $swimlanes[0]['position']);
- $this->assertEquals(2, $swimlanes[0]['id']);
- $this->assertEquals(2, $swimlanes[1]['position']);
- $this->assertEquals(1, $swimlanes[1]['id']);
- $this->assertEquals(3, $swimlanes[2]['position']);
- $this->assertEquals(3, $swimlanes[2]['id']);
-
- $this->assertTrue($swimlaneModel->changePosition(1, 2, 2));
-
- $swimlanes = $swimlaneModel->getAllByStatus(1);
- $this->assertEquals(1, $swimlanes[0]['position']);
- $this->assertEquals(1, $swimlanes[0]['id']);
- $this->assertEquals(2, $swimlanes[1]['position']);
- $this->assertEquals(2, $swimlanes[1]['id']);
- $this->assertEquals(3, $swimlanes[2]['position']);
- $this->assertEquals(3, $swimlanes[2]['id']);
-
- $this->assertTrue($swimlaneModel->changePosition(1, 4, 1));
-
- $swimlanes = $swimlaneModel->getAllByStatus(1);
- $this->assertEquals(1, $swimlanes[0]['position']);
- $this->assertEquals(4, $swimlanes[0]['id']);
- $this->assertEquals(2, $swimlanes[1]['position']);
- $this->assertEquals(1, $swimlanes[1]['id']);
- $this->assertEquals(3, $swimlanes[2]['position']);
- $this->assertEquals(2, $swimlanes[2]['id']);
-
- $this->assertFalse($swimlaneModel->changePosition(1, 2, 0));
- $this->assertFalse($swimlaneModel->changePosition(1, 2, 5));
- }
-
- public function testChangePositionWithInactiveSwimlane()
- {
- $projectModel = new ProjectModel($this->container);
- $swimlaneModel = new SwimlaneModel($this->container);
-
- $this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
- $this->assertEquals(1, $swimlaneModel->create(array('project_id' => 1, 'name' => 'Swimlane #1')));
- $this->assertEquals(2, $swimlaneModel->create(array('project_id' => 1, 'name' => 'Swimlane #2', 'is_active' => 0)));
- $this->assertEquals(3, $swimlaneModel->create(array('project_id' => 1, 'name' => 'Swimlane #3', 'is_active' => 0)));
- $this->assertEquals(4, $swimlaneModel->create(array('project_id' => 1, 'name' => 'Swimlane #4')));
-
- $swimlanes = $swimlaneModel->getAllByStatus(1);
- $this->assertEquals(1, $swimlanes[0]['position']);
- $this->assertEquals(1, $swimlanes[0]['id']);
- $this->assertEquals(2, $swimlanes[1]['position']);
- $this->assertEquals(4, $swimlanes[1]['id']);
-
- $this->assertTrue($swimlaneModel->changePosition(1, 4, 1));
-
- $swimlanes = $swimlaneModel->getAllByStatus(1);
- $this->assertEquals(1, $swimlanes[0]['position']);
- $this->assertEquals(4, $swimlanes[0]['id']);
- $this->assertEquals(2, $swimlanes[1]['position']);
- $this->assertEquals(1, $swimlanes[1]['id']);
- }
-}
diff --git a/tests/units/Model/TaskDuplicationModelTest.php b/tests/units/Model/TaskDuplicationModelTest.php
index 1c42b6a1..1fff110c 100644
--- a/tests/units/Model/TaskDuplicationModelTest.php
+++ b/tests/units/Model/TaskDuplicationModelTest.php
@@ -90,7 +90,7 @@ class TaskDuplicationModelTest extends Base
$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(1, $task['swimlane_id']);
$this->assertEquals(3, $task['column_id']);
$this->assertEquals(2, $task['position']);
$this->assertEquals('test', $task['title']);
diff --git a/tests/units/Model/TaskFinderModelTest.php b/tests/units/Model/TaskFinderModelTest.php
index 9e0369ce..1e3f61cb 100644
--- a/tests/units/Model/TaskFinderModelTest.php
+++ b/tests/units/Model/TaskFinderModelTest.php
@@ -51,7 +51,7 @@ class TaskFinderModelTest extends Base
$this->assertEquals(0, $task['score']);
$this->assertEquals(1, $task['category_id']);
$this->assertEquals(0, $task['priority']);
- $this->assertEquals(0, $task['swimlane_id']);
+ $this->assertEquals(1, $task['swimlane_id']);
$this->assertEquals(TaskModel::RECURRING_STATUS_NONE, $task['recurrence_status']);
$this->assertEquals(TaskModel::RECURRING_TRIGGER_FIRST_COLUMN, $task['recurrence_trigger']);
$this->assertEquals(0, $task['recurrence_factor']);
@@ -60,8 +60,7 @@ class TaskFinderModelTest extends Base
$this->assertEquals(0, $task['recurrence_parent']);
$this->assertEquals(0, $task['recurrence_child']);
$this->assertEquals('C1', $task['category_name']);
- $this->assertNull($task['swimlane_name']);
- $this->assertEquals('Default swimlane', $task['default_swimlane']);
+ $this->assertEquals('Default swimlane', $task['swimlane_name']);
$this->assertEquals('Project #1', $task['project_name']);
$this->assertEquals('Backlog', $task['column_title']);
$this->assertEquals('admin', $task['assignee_username']);
diff --git a/tests/units/Model/TaskPositionModelTest.php b/tests/units/Model/TaskPositionModelTest.php
index 03caf7ed..99154a4f 100644
--- a/tests/units/Model/TaskPositionModelTest.php
+++ b/tests/units/Model/TaskPositionModelTest.php
@@ -422,7 +422,7 @@ class TaskPositionModelTest extends Base
$swimlaneModel = new SwimlaneModel($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'Project #1')));
- $this->assertEquals(1, $swimlaneModel->create(array('project_id' => 1, 'name' => 'test 1')));
+ $this->assertEquals(2, $swimlaneModel->create(1, 'Swimlane #1'));
$this->assertEquals(1, $taskCreationModel->create(array('title' => 'Task #1', 'project_id' => 1, 'column_id' => 1)));
$this->assertEquals(2, $taskCreationModel->create(array('title' => 'Task #2', 'project_id' => 1, 'column_id' => 1)));
$this->assertEquals(3, $taskCreationModel->create(array('title' => 'Task #3', 'project_id' => 1, 'column_id' => 1)));
@@ -430,60 +430,60 @@ class TaskPositionModelTest extends Base
$this->assertEquals(5, $taskCreationModel->create(array('title' => 'Task #5', 'project_id' => 1, 'column_id' => 1)));
// Move the task to the swimlane
- $this->assertTrue($taskPositionModel->movePosition(1, 1, 2, 1, 1));
+ $this->assertTrue($taskPositionModel->movePosition(1, 1, 2, 1, 2));
// Check tasks position
$task = $taskFinderModel->getById(1);
$this->assertEquals(1, $task['id']);
$this->assertEquals(2, $task['column_id']);
$this->assertEquals(1, $task['position']);
- $this->assertEquals(1, $task['swimlane_id']);
+ $this->assertEquals(2, $task['swimlane_id']);
$task = $taskFinderModel->getById(2);
$this->assertEquals(2, $task['id']);
$this->assertEquals(1, $task['column_id']);
$this->assertEquals(1, $task['position']);
- $this->assertEquals(0, $task['swimlane_id']);
+ $this->assertEquals(1, $task['swimlane_id']);
$task = $taskFinderModel->getById(3);
$this->assertEquals(3, $task['id']);
$this->assertEquals(1, $task['column_id']);
$this->assertEquals(2, $task['position']);
- $this->assertEquals(0, $task['swimlane_id']);
+ $this->assertEquals(1, $task['swimlane_id']);
$task = $taskFinderModel->getById(4);
$this->assertEquals(4, $task['id']);
$this->assertEquals(1, $task['column_id']);
$this->assertEquals(3, $task['position']);
- $this->assertEquals(0, $task['swimlane_id']);
+ $this->assertEquals(1, $task['swimlane_id']);
// Move the task to the swimlane
- $this->assertTrue($taskPositionModel->movePosition(1, 2, 2, 1, 1));
+ $this->assertTrue($taskPositionModel->movePosition(1, 2, 2, 1, 2));
// Check tasks position
$task = $taskFinderModel->getById(1);
$this->assertEquals(1, $task['id']);
$this->assertEquals(2, $task['column_id']);
$this->assertEquals(2, $task['position']);
- $this->assertEquals(1, $task['swimlane_id']);
+ $this->assertEquals(2, $task['swimlane_id']);
$task = $taskFinderModel->getById(2);
$this->assertEquals(2, $task['id']);
$this->assertEquals(2, $task['column_id']);
$this->assertEquals(1, $task['position']);
- $this->assertEquals(1, $task['swimlane_id']);
+ $this->assertEquals(2, $task['swimlane_id']);
$task = $taskFinderModel->getById(3);
$this->assertEquals(3, $task['id']);
$this->assertEquals(1, $task['column_id']);
$this->assertEquals(1, $task['position']);
- $this->assertEquals(0, $task['swimlane_id']);
+ $this->assertEquals(1, $task['swimlane_id']);
$task = $taskFinderModel->getById(4);
$this->assertEquals(4, $task['id']);
$this->assertEquals(1, $task['column_id']);
$this->assertEquals(2, $task['position']);
- $this->assertEquals(0, $task['swimlane_id']);
+ $this->assertEquals(1, $task['swimlane_id']);
// Move the task 5 to the last column
$this->assertTrue($taskPositionModel->movePosition(1, 5, 4, 1, 0));
@@ -493,31 +493,31 @@ class TaskPositionModelTest extends Base
$this->assertEquals(1, $task['id']);
$this->assertEquals(2, $task['column_id']);
$this->assertEquals(2, $task['position']);
- $this->assertEquals(1, $task['swimlane_id']);
+ $this->assertEquals(2, $task['swimlane_id']);
$task = $taskFinderModel->getById(2);
$this->assertEquals(2, $task['id']);
$this->assertEquals(2, $task['column_id']);
$this->assertEquals(1, $task['position']);
- $this->assertEquals(1, $task['swimlane_id']);
+ $this->assertEquals(2, $task['swimlane_id']);
$task = $taskFinderModel->getById(3);
$this->assertEquals(3, $task['id']);
$this->assertEquals(1, $task['column_id']);
$this->assertEquals(1, $task['position']);
- $this->assertEquals(0, $task['swimlane_id']);
+ $this->assertEquals(1, $task['swimlane_id']);
$task = $taskFinderModel->getById(4);
$this->assertEquals(4, $task['id']);
$this->assertEquals(1, $task['column_id']);
$this->assertEquals(2, $task['position']);
- $this->assertEquals(0, $task['swimlane_id']);
+ $this->assertEquals(1, $task['swimlane_id']);
$task = $taskFinderModel->getById(5);
$this->assertEquals(5, $task['id']);
$this->assertEquals(4, $task['column_id']);
$this->assertEquals(1, $task['position']);
- $this->assertEquals(0, $task['swimlane_id']);
+ $this->assertEquals(1, $task['swimlane_id']);
}
public function testEvents()
@@ -529,7 +529,7 @@ class TaskPositionModelTest extends Base
$swimlaneModel = new SwimlaneModel($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'Project #1')));
- $this->assertEquals(1, $swimlaneModel->create(array('project_id' => 1, 'name' => 'test 1')));
+ $this->assertEquals(2, $swimlaneModel->create(1, 'Swimlane #1'));
$this->assertEquals(1, $taskCreationModel->create(array('title' => 'Task #1', 'project_id' => 1, 'column_id' => 1)));
$this->assertEquals(2, $taskCreationModel->create(array('title' => 'Task #2', 'project_id' => 1, 'column_id' => 2)));
@@ -573,19 +573,19 @@ class TaskPositionModelTest extends Base
$this->assertEquals(2, count($called));
// Move to another swimlane
- $this->assertTrue($taskPositionModel->movePosition(1, 1, 3, 1, 1));
+ $this->assertTrue($taskPositionModel->movePosition(1, 1, 3, 1, 2));
$task = $taskFinderModel->getById(1);
$this->assertEquals(1, $task['id']);
$this->assertEquals(3, $task['column_id']);
$this->assertEquals(1, $task['position']);
- $this->assertEquals(1, $task['swimlane_id']);
+ $this->assertEquals(2, $task['swimlane_id']);
$task = $taskFinderModel->getById(2);
$this->assertEquals(2, $task['id']);
$this->assertEquals(2, $task['column_id']);
$this->assertEquals(1, $task['position']);
- $this->assertEquals(0, $task['swimlane_id']);
+ $this->assertEquals(1, $task['swimlane_id']);
$called = $this->container['dispatcher']->getCalledListeners();
$this->assertArrayHasKey(TaskModel::EVENT_MOVE_SWIMLANE.'.TaskPositionModelTest::onMoveSwimlane', $called);
@@ -626,6 +626,6 @@ class TaskPositionModelTest extends Base
$this->assertEquals(1, $event_data['position']);
$this->assertEquals(3, $event_data['column_id']);
$this->assertEquals(1, $event_data['project_id']);
- $this->assertEquals(1, $event_data['swimlane_id']);
+ $this->assertEquals(2, $event_data['swimlane_id']);
}
}
diff --git a/tests/units/Model/TaskProjectDuplicationModelTest.php b/tests/units/Model/TaskProjectDuplicationModelTest.php
index 9ff33bc1..68e37cd5 100644
--- a/tests/units/Model/TaskProjectDuplicationModelTest.php
+++ b/tests/units/Model/TaskProjectDuplicationModelTest.php
@@ -55,7 +55,7 @@ class TaskProjectDuplicationModelTest extends Base
$this->assertNotEmpty($task);
$this->assertEquals(0, $task['owner_id']);
$this->assertEquals(0, $task['category_id']);
- $this->assertEquals(0, $task['swimlane_id']);
+ $this->assertEquals(2, $task['swimlane_id']);
$this->assertEquals(6, $task['column_id']);
$this->assertEquals(1, $task['position']);
$this->assertEquals(2, $task['project_id']);
@@ -91,7 +91,7 @@ class TaskProjectDuplicationModelTest extends Base
$this->assertNotEmpty($task);
$this->assertEquals(0, $task['owner_id']);
$this->assertEquals(2, $task['category_id']);
- $this->assertEquals(0, $task['swimlane_id']);
+ $this->assertEquals(2, $task['swimlane_id']);
$this->assertEquals(6, $task['column_id']);
$this->assertEquals(1, $task['position']);
$this->assertEquals(2, $task['project_id']);
@@ -149,8 +149,8 @@ class TaskProjectDuplicationModelTest extends Base
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
$this->assertEquals(2, $projectModel->create(array('name' => 'test2')));
- $this->assertNotFalse($swimlaneModel->create(array('project_id' => 1, 'name' => 'Swimlane #1')));
- $this->assertNotFalse($swimlaneModel->create(array('project_id' => 2, 'name' => 'Swimlane #1')));
+ $this->assertEquals(3, $swimlaneModel->create(1, 'Swimlane #1'));
+ $this->assertEquals(4, $swimlaneModel->create(2, 'Swimlane #2'));
// We create a task
$this->assertEquals(1, $taskCreationModel->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 2, 'swimlane_id' => 1)));
@@ -182,11 +182,11 @@ class TaskProjectDuplicationModelTest extends Base
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
$this->assertEquals(2, $projectModel->create(array('name' => 'test2')));
- $this->assertNotFalse($swimlaneModel->create(array('project_id' => 1, 'name' => 'Swimlane #1')));
- $this->assertNotFalse($swimlaneModel->create(array('project_id' => 2, 'name' => 'Swimlane #2')));
+ $this->assertEquals(3, $swimlaneModel->create(1, 'Swimlane #1'));
+ $this->assertEquals(4, $swimlaneModel->create(1, 'Swimlane #2'));
// We create a task
- $this->assertEquals(1, $taskCreationModel->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 2, 'swimlane_id' => 1)));
+ $this->assertEquals(1, $taskCreationModel->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 2, 'swimlane_id' => 2)));
// We duplicate our task to the 2nd project
$this->assertEquals(2, $taskProjectDuplicationModel->duplicateToProject(1, 2));
@@ -196,7 +196,7 @@ class TaskProjectDuplicationModelTest extends Base
$this->assertNotEmpty($task);
$this->assertEquals(0, $task['owner_id']);
$this->assertEquals(0, $task['category_id']);
- $this->assertEquals(0, $task['swimlane_id']);
+ $this->assertEquals(2, $task['swimlane_id']);
$this->assertEquals(6, $task['column_id']);
$this->assertEquals(1, $task['position']);
$this->assertEquals(2, $task['project_id']);
@@ -215,12 +215,12 @@ class TaskProjectDuplicationModelTest extends Base
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
$this->assertEquals(2, $projectModel->create(array('name' => 'test2')));
- $this->assertNotFalse($swimlaneModel->create(array('project_id' => 1, 'name' => 'Swimlane #1')));
- $this->assertNotFalse($swimlaneModel->create(array('project_id' => 2, 'name' => 'Swimlane #1')));
- $this->assertNotFalse($swimlaneModel->create(array('project_id' => 2, 'name' => 'Swimlane #2')));
+ $this->assertEquals(3, $swimlaneModel->create(1, 'Swimlane #1'));
+ $this->assertEquals(4, $swimlaneModel->create(2, 'Swimlane #1'));
+ $this->assertEquals(5, $swimlaneModel->create(2, 'Swimlane #2'));
// We create a task
- $this->assertEquals(1, $taskCreationModel->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 2, 'swimlane_id' => 1)));
+ $this->assertEquals(1, $taskCreationModel->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 2, 'swimlane_id' => 2)));
// We duplicate our task to the 2nd project
$this->assertEquals(2, $taskProjectDuplicationModel->duplicateToProject(1, 2, 3));
@@ -228,7 +228,7 @@ class TaskProjectDuplicationModelTest extends Base
// Check the values of the duplicated task
$task = $taskFinderModel->getById(2);
$this->assertNotEmpty($task);
- $this->assertEquals(3, $task['swimlane_id']);
+ $this->assertEquals(4, $task['swimlane_id']);
}
public function testDuplicateAnotherProjectWithPredefinedColumn()
diff --git a/tests/units/Model/TaskProjectMoveModelTest.php b/tests/units/Model/TaskProjectMoveModelTest.php
index 52f61b28..28155b8f 100644
--- a/tests/units/Model/TaskProjectMoveModelTest.php
+++ b/tests/units/Model/TaskProjectMoveModelTest.php
@@ -61,7 +61,7 @@ class TaskProjectMoveModelTest extends Base
$this->assertNotEmpty($task);
$this->assertEquals(0, $task['owner_id']);
$this->assertEquals(0, $task['category_id']);
- $this->assertEquals(0, $task['swimlane_id']);
+ $this->assertEquals(2, $task['swimlane_id']);
$this->assertEquals(2, $task['project_id']);
$this->assertEquals(5, $task['column_id']);
$this->assertEquals(1, $task['position']);
@@ -97,7 +97,7 @@ class TaskProjectMoveModelTest extends Base
$this->assertNotEmpty($task);
$this->assertEquals(0, $task['owner_id']);
$this->assertEquals(2, $task['category_id']);
- $this->assertEquals(0, $task['swimlane_id']);
+ $this->assertEquals(2, $task['swimlane_id']);
$this->assertEquals(6, $task['column_id']);
$this->assertEquals(1, $task['position']);
$this->assertEquals(2, $task['project_id']);
@@ -182,11 +182,11 @@ class TaskProjectMoveModelTest extends Base
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
$this->assertEquals(2, $projectModel->create(array('name' => 'test2')));
- $this->assertNotFalse($swimlaneModel->create(array('project_id' => 1, 'name' => 'Swimlane #1')));
- $this->assertNotFalse($swimlaneModel->create(array('project_id' => 2, 'name' => 'Swimlane #1')));
+ $this->assertEquals(3, $swimlaneModel->create(1, 'Swimlane #1'));
+ $this->assertEquals(4, $swimlaneModel->create(2, 'Swimlane #1'));
// We create a task
- $this->assertEquals(1, $taskCreationModel->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 2, 'swimlane_id' => 1)));
+ $this->assertEquals(1, $taskCreationModel->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 2, 'swimlane_id' => 3)));
// We move our task to the 2nd project
$this->assertTrue($taskProjectMoveModel->moveToProject(1, 2));
@@ -196,7 +196,7 @@ class TaskProjectMoveModelTest extends Base
$this->assertNotEmpty($task);
$this->assertEquals(0, $task['owner_id']);
$this->assertEquals(0, $task['category_id']);
- $this->assertEquals(2, $task['swimlane_id']);
+ $this->assertEquals(4, $task['swimlane_id']);
$this->assertEquals(6, $task['column_id']);
$this->assertEquals(1, $task['position']);
$this->assertEquals(2, $task['project_id']);
@@ -215,11 +215,11 @@ class TaskProjectMoveModelTest extends Base
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
$this->assertEquals(2, $projectModel->create(array('name' => 'test2')));
- $this->assertNotFalse($swimlaneModel->create(array('project_id' => 1, 'name' => 'Swimlane #1')));
- $this->assertNotFalse($swimlaneModel->create(array('project_id' => 2, 'name' => 'Swimlane #2')));
+ $this->assertEquals(3, $swimlaneModel->create(1, 'Swimlane #1'));
+ $this->assertEquals(4, $swimlaneModel->create(2, 'Swimlane #2'));
// We create a task
- $this->assertEquals(1, $taskCreationModel->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 2, 'swimlane_id' => 1)));
+ $this->assertEquals(1, $taskCreationModel->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 2, 'swimlane_id' => 3)));
// We move our task to the 2nd project
$this->assertTrue($taskProjectMoveModel->moveToProject(1, 2));
@@ -229,7 +229,7 @@ class TaskProjectMoveModelTest extends Base
$this->assertNotEmpty($task);
$this->assertEquals(0, $task['owner_id']);
$this->assertEquals(0, $task['category_id']);
- $this->assertEquals(0, $task['swimlane_id']);
+ $this->assertEquals(2, $task['swimlane_id']);
$this->assertEquals(6, $task['column_id']);
$this->assertEquals(1, $task['position']);
$this->assertEquals(2, $task['project_id']);
diff --git a/tests/units/Model/TaskStatusModelTest.php b/tests/units/Model/TaskStatusModelTest.php
new file mode 100644
index 00000000..157ed3e2
--- /dev/null
+++ b/tests/units/Model/TaskStatusModelTest.php
@@ -0,0 +1,143 @@
+<?php
+
+require_once __DIR__.'/../Base.php';
+
+use Kanboard\Model\SwimlaneModel;
+use Kanboard\Model\SubtaskModel;
+use Kanboard\Model\TaskModel;
+use Kanboard\Model\TaskCreationModel;
+use Kanboard\Model\TaskFinderModel;
+use Kanboard\Model\TaskStatusModel;
+use Kanboard\Model\ProjectModel;
+
+class TaskStatusModelTest extends Base
+{
+ public function testCloseBySwimlaneAndColumn()
+ {
+ $taskCreationModel = new TaskCreationModel($this->container);
+ $taskFinderModel = new TaskFinderModel($this->container);
+ $taskStatusModel = new TaskStatusModel($this->container);
+ $projectModel = new ProjectModel($this->container);
+ $swimlaneModel = new SwimlaneModel($this->container);
+
+ $this->assertEquals(1, $projectModel->create(array('name' => 'test')));
+ $this->assertEquals(2, $swimlaneModel->create(1, 'Swimlane #1'));
+ $this->assertEquals(1, $taskCreationModel->create(array('title' => 'test', 'project_id' => 1)));
+ $this->assertEquals(2, $taskCreationModel->create(array('title' => 'test', 'project_id' => 1)));
+ $this->assertEquals(3, $taskCreationModel->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 2)));
+ $this->assertEquals(4, $taskCreationModel->create(array('title' => 'test', 'project_id' => 1, 'swimlane_id' => 2)));
+ $this->assertEquals(5, $taskCreationModel->create(array('title' => 'test', 'project_id' => 1, 'is_active' => 0, 'date_completed' => strtotime('2015-01-01'))));
+
+ $taskBefore = $taskFinderModel->getById(5);
+
+ $this->assertEquals(2, $taskFinderModel->countByColumnAndSwimlaneId(1, 1, 1));
+ $this->assertEquals(1, $taskFinderModel->countByColumnAndSwimlaneId(1, 1, 2));
+ $this->assertEquals(1, $taskFinderModel->countByColumnAndSwimlaneId(1, 2, 1));
+
+ $taskStatusModel->closeTasksBySwimlaneAndColumn(1, 1);
+ $this->assertEquals(0, $taskFinderModel->countByColumnAndSwimlaneId(1, 1, 1));
+ $this->assertEquals(1, $taskFinderModel->countByColumnAndSwimlaneId(1, 1, 2));
+ $this->assertEquals(1, $taskFinderModel->countByColumnAndSwimlaneId(1, 2, 1));
+
+ $taskStatusModel->closeTasksBySwimlaneAndColumn(2, 1);
+ $this->assertEquals(0, $taskFinderModel->countByColumnAndSwimlaneId(1, 1, 1));
+ $this->assertEquals(0, $taskFinderModel->countByColumnAndSwimlaneId(1, 1, 2));
+ $this->assertEquals(1, $taskFinderModel->countByColumnAndSwimlaneId(1, 2, 1));
+
+ $taskStatusModel->closeTasksBySwimlaneAndColumn(1, 2);
+ $this->assertEquals(0, $taskFinderModel->countByColumnAndSwimlaneId(1, 1, 1));
+ $this->assertEquals(0, $taskFinderModel->countByColumnAndSwimlaneId(1, 1, 2));
+ $this->assertEquals(0, $taskFinderModel->countByColumnAndSwimlaneId(1, 2, 1));
+
+ $taskAfter = $taskFinderModel->getById(5);
+ $this->assertEquals(strtotime('2015-01-01'), $taskAfter['date_completed']);
+ $this->assertEquals($taskBefore['date_modification'], $taskAfter['date_modification']);
+ }
+
+ public function testStatus()
+ {
+ $taskCreationModel = new TaskCreationModel($this->container);
+ $taskFinderModel = new TaskFinderModel($this->container);
+ $taskStatusModel = new TaskStatusModel($this->container);
+ $projectModel = new ProjectModel($this->container);
+
+ $this->assertEquals(1, $projectModel->create(array('name' => 'test')));
+ $this->assertEquals(1, $taskCreationModel->create(array('title' => 'test', 'project_id' => 1)));
+
+ // The task must be open
+
+ $this->assertTrue($taskStatusModel->isOpen(1));
+
+ $task = $taskFinderModel->getById(1);
+ $this->assertNotEmpty($task);
+ $this->assertEquals(TaskModel::STATUS_OPEN, $task['is_active']);
+ $this->assertEquals(0, $task['date_completed']);
+ $this->assertEquals(time(), $task['date_modification'], '', 1);
+
+ // We close the task
+
+ $this->container['dispatcher']->addListener(TaskModel::EVENT_CLOSE, array($this, 'onTaskClose'));
+ $this->container['dispatcher']->addListener(TaskModel::EVENT_OPEN, array($this, 'onTaskOpen'));
+
+ $this->assertTrue($taskStatusModel->close(1));
+ $this->assertTrue($taskStatusModel->isClosed(1));
+
+ $task = $taskFinderModel->getById(1);
+ $this->assertNotEmpty($task);
+ $this->assertEquals(TaskModel::STATUS_CLOSED, $task['is_active']);
+ $this->assertEquals(time(), $task['date_completed'], 'Bad completion timestamp', 1);
+ $this->assertEquals(time(), $task['date_modification'], 'Bad modification timestamp', 1);
+
+ // We open the task again
+
+ $this->assertTrue($taskStatusModel->open(1));
+ $this->assertTrue($taskStatusModel->isOpen(1));
+
+ $task = $taskFinderModel->getById(1);
+ $this->assertNotEmpty($task);
+ $this->assertEquals(TaskModel::STATUS_OPEN, $task['is_active']);
+ $this->assertEquals(0, $task['date_completed']);
+ $this->assertEquals(time(), $task['date_modification'], '', 1);
+
+ $called = $this->container['dispatcher']->getCalledListeners();
+ $this->assertArrayHasKey('task.close.TaskStatusModelTest::onTaskClose', $called);
+ $this->assertArrayHasKey('task.open.TaskStatusModelTest::onTaskOpen', $called);
+ }
+
+ public function onTaskOpen($event)
+ {
+ $this->assertInstanceOf('Kanboard\Event\TaskEvent', $event);
+ $this->assertArrayHasKey('task_id', $event);
+ $this->assertNotEmpty($event['task_id']);
+ }
+
+ public function onTaskClose($event)
+ {
+ $this->assertInstanceOf('Kanboard\Event\TaskEvent', $event);
+ $this->assertArrayHasKey('task_id', $event);
+ $this->assertNotEmpty($event['task_id']);
+ }
+
+ public function testThatAllSubtasksAreClosed()
+ {
+ $taskStatusModel = new TaskStatusModel($this->container);
+ $taskCreationModel = new TaskCreationModel($this->container);
+ $subtaskModel = new SubtaskModel($this->container);
+ $projectModel = new ProjectModel($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)));
+ $this->assertEquals(2, $subtaskModel->create(array('title' => 'subtask #2', 'task_id' => 1)));
+
+ $this->assertTrue($taskStatusModel->close(1));
+
+ $subtasks = $subtaskModel->getAll(1);
+ $this->assertNotEmpty($subtasks);
+
+ foreach ($subtasks as $subtask) {
+ $this->assertEquals(SubtaskModel::STATUS_DONE, $subtask['status']);
+ }
+ }
+}
diff --git a/tests/units/Model/TaskStatusTest.php b/tests/units/Model/TaskStatusTest.php
deleted file mode 100644
index f011409d..00000000
--- a/tests/units/Model/TaskStatusTest.php
+++ /dev/null
@@ -1,143 +0,0 @@
-<?php
-
-require_once __DIR__.'/../Base.php';
-
-use Kanboard\Model\SwimlaneModel;
-use Kanboard\Model\SubtaskModel;
-use Kanboard\Model\TaskModel;
-use Kanboard\Model\TaskCreationModel;
-use Kanboard\Model\TaskFinderModel;
-use Kanboard\Model\TaskStatusModel;
-use Kanboard\Model\ProjectModel;
-
-class TaskStatusTest extends Base
-{
- public function testCloseBySwimlaneAndColumn()
- {
- $tc = new TaskCreationModel($this->container);
- $tf = new TaskFinderModel($this->container);
- $ts = new TaskStatusModel($this->container);
- $p = new ProjectModel($this->container);
- $s = new SwimlaneModel($this->container);
-
- $this->assertEquals(1, $p->create(array('name' => 'test')));
- $this->assertEquals(1, $s->create(array('name' => 'test', 'project_id' => 1)));
- $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1)));
- $this->assertEquals(2, $tc->create(array('title' => 'test', 'project_id' => 1)));
- $this->assertEquals(3, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 2)));
- $this->assertEquals(4, $tc->create(array('title' => 'test', 'project_id' => 1, 'swimlane_id' => 1)));
- $this->assertEquals(5, $tc->create(array('title' => 'test', 'project_id' => 1, 'is_active' => 0, 'date_completed' => strtotime('2015-01-01'))));
-
- $taskBefore = $tf->getById(5);
-
- $this->assertEquals(2, $tf->countByColumnAndSwimlaneId(1, 1, 0));
- $this->assertEquals(1, $tf->countByColumnAndSwimlaneId(1, 1, 1));
- $this->assertEquals(1, $tf->countByColumnAndSwimlaneId(1, 2, 0));
-
- $ts->closeTasksBySwimlaneAndColumn(0, 1);
- $this->assertEquals(0, $tf->countByColumnAndSwimlaneId(1, 1, 0));
- $this->assertEquals(1, $tf->countByColumnAndSwimlaneId(1, 1, 1));
- $this->assertEquals(1, $tf->countByColumnAndSwimlaneId(1, 2, 0));
-
- $ts->closeTasksBySwimlaneAndColumn(1, 1);
- $this->assertEquals(0, $tf->countByColumnAndSwimlaneId(1, 1, 0));
- $this->assertEquals(0, $tf->countByColumnAndSwimlaneId(1, 1, 1));
- $this->assertEquals(1, $tf->countByColumnAndSwimlaneId(1, 2, 0));
-
- $ts->closeTasksBySwimlaneAndColumn(0, 2);
- $this->assertEquals(0, $tf->countByColumnAndSwimlaneId(1, 1, 0));
- $this->assertEquals(0, $tf->countByColumnAndSwimlaneId(1, 1, 1));
- $this->assertEquals(0, $tf->countByColumnAndSwimlaneId(1, 2, 0));
-
- $taskAfter = $tf->getById(5);
- $this->assertEquals(strtotime('2015-01-01'), $taskAfter['date_completed']);
- $this->assertEquals($taskBefore['date_modification'], $taskAfter['date_modification']);
- }
-
- public function testStatus()
- {
- $tc = new TaskCreationModel($this->container);
- $tf = new TaskFinderModel($this->container);
- $ts = new TaskStatusModel($this->container);
- $p = new ProjectModel($this->container);
-
- $this->assertEquals(1, $p->create(array('name' => 'test')));
- $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1)));
-
- // The task must be open
-
- $this->assertTrue($ts->isOpen(1));
-
- $task = $tf->getById(1);
- $this->assertNotEmpty($task);
- $this->assertEquals(TaskModel::STATUS_OPEN, $task['is_active']);
- $this->assertEquals(0, $task['date_completed']);
- $this->assertEquals(time(), $task['date_modification'], '', 1);
-
- // We close the task
-
- $this->container['dispatcher']->addListener(TaskModel::EVENT_CLOSE, array($this, 'onTaskClose'));
- $this->container['dispatcher']->addListener(TaskModel::EVENT_OPEN, array($this, 'onTaskOpen'));
-
- $this->assertTrue($ts->close(1));
- $this->assertTrue($ts->isClosed(1));
-
- $task = $tf->getById(1);
- $this->assertNotEmpty($task);
- $this->assertEquals(TaskModel::STATUS_CLOSED, $task['is_active']);
- $this->assertEquals(time(), $task['date_completed'], 'Bad completion timestamp', 1);
- $this->assertEquals(time(), $task['date_modification'], 'Bad modification timestamp', 1);
-
- // We open the task again
-
- $this->assertTrue($ts->open(1));
- $this->assertTrue($ts->isOpen(1));
-
- $task = $tf->getById(1);
- $this->assertNotEmpty($task);
- $this->assertEquals(TaskModel::STATUS_OPEN, $task['is_active']);
- $this->assertEquals(0, $task['date_completed']);
- $this->assertEquals(time(), $task['date_modification'], '', 1);
-
- $called = $this->container['dispatcher']->getCalledListeners();
- $this->assertArrayHasKey('task.close.TaskStatusTest::onTaskClose', $called);
- $this->assertArrayHasKey('task.open.TaskStatusTest::onTaskOpen', $called);
- }
-
- public function onTaskOpen($event)
- {
- $this->assertInstanceOf('Kanboard\Event\TaskEvent', $event);
- $this->assertArrayHasKey('task_id', $event);
- $this->assertNotEmpty($event['task_id']);
- }
-
- public function onTaskClose($event)
- {
- $this->assertInstanceOf('Kanboard\Event\TaskEvent', $event);
- $this->assertArrayHasKey('task_id', $event);
- $this->assertNotEmpty($event['task_id']);
- }
-
- public function testThatAllSubtasksAreClosed()
- {
- $ts = new TaskStatusModel($this->container);
- $tc = new TaskCreationModel($this->container);
- $s = new SubtaskModel($this->container);
- $p = new ProjectModel($this->container);
-
- $this->assertEquals(1, $p->create(array('name' => 'test1')));
- $this->assertEquals(1, $tc->create(array('title' => 'test 1', 'project_id' => 1)));
-
- $this->assertEquals(1, $s->create(array('title' => 'subtask #1', 'task_id' => 1)));
- $this->assertEquals(2, $s->create(array('title' => 'subtask #2', 'task_id' => 1)));
-
- $this->assertTrue($ts->close(1));
-
- $subtasks = $s->getAll(1);
- $this->assertNotEmpty($subtasks);
-
- foreach ($subtasks as $subtask) {
- $this->assertEquals(SubtaskModel::STATUS_DONE, $subtask['status']);
- }
- }
-}
diff --git a/tests/units/Validator/TaskValidatorTest.php b/tests/units/Validator/TaskValidatorTest.php
index f6530027..e9d9ac09 100644
--- a/tests/units/Validator/TaskValidatorTest.php
+++ b/tests/units/Validator/TaskValidatorTest.php
@@ -39,4 +39,15 @@ class TaskValidatorTest extends Base
$result = $taskValidator->validateCreation(array('project_id' => 1, 'title' => 'test', 'score' => -2147483648));
$this->assertFalse($result[0]);
}
+
+ public function testSwimlaneIdField()
+ {
+ $taskValidator = new TaskValidator($this->container);
+
+ $result = $taskValidator->validateCreation(array('project_id' => 1, 'title' => 'test', 'swimlane_id' => 1));
+ $this->assertTrue($result[0]);
+
+ $result = $taskValidator->validateCreation(array('project_id' => 1, 'title' => 'test', 'swimlane_id' => 0));
+ $this->assertFalse($result[0]);
+ }
}