summaryrefslogtreecommitdiff
path: root/tests/units
diff options
context:
space:
mode:
Diffstat (limited to 'tests/units')
-rw-r--r--tests/units/BoardTest.php11
-rw-r--r--tests/units/SwimlaneTest.php363
-rw-r--r--tests/units/TaskDuplicationTest.php142
-rw-r--r--tests/units/TaskPositionTest.php108
4 files changed, 619 insertions, 5 deletions
diff --git a/tests/units/BoardTest.php b/tests/units/BoardTest.php
index a7de34bd..866d3bab 100644
--- a/tests/units/BoardTest.php
+++ b/tests/units/BoardTest.php
@@ -48,11 +48,14 @@ class BoardTest extends Base
$this->assertEquals(1, $p->create(array('name' => 'UnitTest1')));
- $board = $b->get(1);
+ $board = $b->getBoard(1);
$this->assertNotEmpty($board);
- $this->assertEquals(4, count($board));
- $this->assertTrue(array_key_exists('tasks', $board[2]));
- $this->assertTrue(array_key_exists('title', $board[2]));
+ $this->assertEquals(1, count($board));
+ $this->assertEquals(4, count($board[0]));
+ $this->assertTrue(array_key_exists('name', $board[0]));
+ $this->assertTrue(array_key_exists('columns', $board[0]));
+ $this->assertTrue(array_key_exists('tasks', $board[0]['columns'][2]));
+ $this->assertTrue(array_key_exists('title', $board[0]['columns'][2]));
}
public function testGetColumn()
diff --git a/tests/units/SwimlaneTest.php b/tests/units/SwimlaneTest.php
new file mode 100644
index 00000000..0c0cdfc5
--- /dev/null
+++ b/tests/units/SwimlaneTest.php
@@ -0,0 +1,363 @@
+<?php
+
+require_once __DIR__.'/Base.php';
+
+use Model\Project;
+use Model\Task;
+use Model\TaskCreation;
+use Model\TaskFinder;
+use Model\Swimlane;
+
+class SwimlaneTest extends Base
+{
+ public function testCreation()
+ {
+ $p = new Project($this->container);
+ $s = new Swimlane($this->container);
+
+ $this->assertEquals(1, $p->create(array('name' => 'UnitTest')));
+ $this->assertEquals(1, $s->create(1, '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 testRename()
+ {
+ $p = new Project($this->container);
+ $s = new Swimlane($this->container);
+
+ $this->assertEquals(1, $p->create(array('name' => 'UnitTest')));
+ $this->assertEquals(1, $s->create(1, 'Swimlane #1'));
+
+ $swimlane = $s->getById(1);
+ $this->assertNotEmpty($swimlane);
+ $this->assertEquals('Swimlane #1', $swimlane['name']);
+
+ $this->assertTrue($s->rename(1, 'foobar'));
+
+ $swimlane = $s->getById(1);
+ $this->assertNotEmpty($swimlane);
+ $this->assertEquals('foobar', $swimlane['name']);
+ }
+
+ public function testRenameDefaultSwimlane()
+ {
+ $p = new Project($this->container);
+ $s = new Swimlane($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 testDisable()
+ {
+ $p = new Project($this->container);
+ $s = new Swimlane($this->container);
+
+ $this->assertEquals(1, $p->create(array('name' => 'UnitTest')));
+ $this->assertEquals(1, $s->create(1, '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(1, '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 Project($this->container);
+ $s = new Swimlane($this->container);
+ $tc = new TaskCreation($this->container);
+ $tf = new TaskFinder($this->container);
+
+ $this->assertEquals(1, $p->create(array('name' => 'UnitTest')));
+ $this->assertEquals(1, $s->create(1, '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 Project($this->container);
+ $s = new Swimlane($this->container);
+
+ $this->assertEquals(1, $p->create(array('name' => 'UnitTest')));
+ $this->assertEquals(1, $s->create(1, 'Swimlane #1'));
+ $this->assertEquals(2, $s->create(1, 'Swimlane #2'));
+ $this->assertEquals(3, $s->create(1, '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 testMoveUp()
+ {
+ $p = new Project($this->container);
+ $s = new Swimlane($this->container);
+
+ $this->assertEquals(1, $p->create(array('name' => 'UnitTest')));
+ $this->assertEquals(1, $s->create(1, 'Swimlane #1'));
+ $this->assertEquals(2, $s->create(1, 'Swimlane #2'));
+ $this->assertEquals(3, $s->create(1, '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']);
+
+ // Move the swimlane 3 up
+ $this->assertTrue($s->moveUp(1, 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(3, $swimlane['position']);
+
+ $swimlane = $s->getById(3);
+ $this->assertNotEmpty($swimlane);
+ $this->assertEquals(1, $swimlane['is_active']);
+ $this->assertEquals(2, $swimlane['position']);
+
+ // First swimlane can be moved up
+ $this->assertFalse($s->moveUp(1, 1));
+
+ // Move with a disabled swimlane
+ $this->assertTrue($s->disable(1, 1));
+
+ $swimlane = $s->getById(1);
+ $this->assertNotEmpty($swimlane);
+ $this->assertEquals(0, $swimlane['is_active']);
+ $this->assertEquals(0, $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(1, $swimlane['position']);
+
+ // Move the 2nd swimlane up
+ $this->assertTrue($s->moveUp(1, 2));
+
+ $swimlane = $s->getById(1);
+ $this->assertNotEmpty($swimlane);
+ $this->assertEquals(0, $swimlane['is_active']);
+ $this->assertEquals(0, $swimlane['position']);
+
+ $swimlane = $s->getById(2);
+ $this->assertNotEmpty($swimlane);
+ $this->assertEquals(1, $swimlane['is_active']);
+ $this->assertEquals(1, $swimlane['position']);
+
+ $swimlane = $s->getById(3);
+ $this->assertNotEmpty($swimlane);
+ $this->assertEquals(1, $swimlane['is_active']);
+ $this->assertEquals(2, $swimlane['position']);
+ }
+
+ public function testMoveDown()
+ {
+ $p = new Project($this->container);
+ $s = new Swimlane($this->container);
+
+ $this->assertEquals(1, $p->create(array('name' => 'UnitTest')));
+ $this->assertEquals(1, $s->create(1, 'Swimlane #1'));
+ $this->assertEquals(2, $s->create(1, 'Swimlane #2'));
+ $this->assertEquals(3, $s->create(1, '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']);
+
+ // Move the swimlane 1 down
+ $this->assertTrue($s->moveDown(1, 1));
+
+ $swimlane = $s->getById(1);
+ $this->assertNotEmpty($swimlane);
+ $this->assertEquals(1, $swimlane['is_active']);
+ $this->assertEquals(2, $swimlane['position']);
+
+ $swimlane = $s->getById(2);
+ $this->assertNotEmpty($swimlane);
+ $this->assertEquals(1, $swimlane['is_active']);
+ $this->assertEquals(1, $swimlane['position']);
+
+ $swimlane = $s->getById(3);
+ $this->assertNotEmpty($swimlane);
+ $this->assertEquals(1, $swimlane['is_active']);
+ $this->assertEquals(3, $swimlane['position']);
+
+ // Last swimlane can be moved down
+ $this->assertFalse($s->moveDown(1, 3));
+
+ // Move with a disabled swimlane
+ $this->assertTrue($s->disable(1, 3));
+
+ $swimlane = $s->getById(1);
+ $this->assertNotEmpty($swimlane);
+ $this->assertEquals(1, $swimlane['is_active']);
+ $this->assertEquals(2, $swimlane['position']);
+
+ $swimlane = $s->getById(2);
+ $this->assertNotEmpty($swimlane);
+ $this->assertEquals(1, $swimlane['is_active']);
+ $this->assertEquals(1, $swimlane['position']);
+
+ $swimlane = $s->getById(3);
+ $this->assertNotEmpty($swimlane);
+ $this->assertEquals(0, $swimlane['is_active']);
+ $this->assertEquals(0, $swimlane['position']);
+
+ // Move the 2st swimlane down
+ $this->assertTrue($s->moveDown(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(1, $swimlane['is_active']);
+ $this->assertEquals(2, $swimlane['position']);
+
+ $swimlane = $s->getById(3);
+ $this->assertNotEmpty($swimlane);
+ $this->assertEquals(0, $swimlane['is_active']);
+ $this->assertEquals(0, $swimlane['position']);
+ }
+}
diff --git a/tests/units/TaskDuplicationTest.php b/tests/units/TaskDuplicationTest.php
index 80f037de..7b2983f8 100644
--- a/tests/units/TaskDuplicationTest.php
+++ b/tests/units/TaskDuplicationTest.php
@@ -11,6 +11,7 @@ use Model\Project;
use Model\ProjectPermission;
use Model\Category;
use Model\User;
+use Model\Swimlane;
class TaskDuplicationTest extends Base
{
@@ -56,6 +57,7 @@ class TaskDuplicationTest 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(3, $task['column_id']);
$this->assertEquals(2, $task['position']);
$this->assertEquals('test', $task['title']);
@@ -90,6 +92,7 @@ class TaskDuplicationTest extends Base
$this->assertNotEmpty($task);
$this->assertEquals(1, $task['owner_id']);
$this->assertEquals(0, $task['category_id']);
+ $this->assertEquals(0, $task['swimlane_id']);
$this->assertEquals(5, $task['column_id']);
$this->assertEquals(1, $task['position']);
$this->assertEquals(2, $task['project_id']);
@@ -126,6 +129,77 @@ class TaskDuplicationTest 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(5, $task['column_id']);
+ $this->assertEquals(1, $task['position']);
+ $this->assertEquals(2, $task['project_id']);
+ $this->assertEquals('test', $task['title']);
+ }
+
+ public function testDuplicateAnotherProjectWithSwimlane()
+ {
+ $td = new TaskDuplication($this->container);
+ $tc = new TaskCreation($this->container);
+ $tf = new TaskFinder($this->container);
+ $p = new Project($this->container);
+ $s = new Swimlane($this->container);
+
+ // We create 2 projects
+ $this->assertEquals(1, $p->create(array('name' => 'test1')));
+ $this->assertEquals(2, $p->create(array('name' => 'test2')));
+
+ $this->assertNotFalse($s->create(1, 'Swimlane #1'));
+ $this->assertNotFalse($s->create(2, 'Swimlane #1'));
+
+ // We create a task
+ $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 2, 'swimlane_id' => 1)));
+
+ // We duplicate our task to the 2nd project
+ $this->assertEquals(2, $td->duplicateToProject(1, 2));
+ $this->assertTrue($this->container['event']->isEventTriggered(Task::EVENT_CREATE));
+ $this->assertTrue($this->container['event']->isEventTriggered(Task::EVENT_CREATE_UPDATE));
+
+ // Check the values of the duplicated task
+ $task = $tf->getById(2);
+ $this->assertNotEmpty($task);
+ $this->assertEquals(0, $task['owner_id']);
+ $this->assertEquals(0, $task['category_id']);
+ $this->assertEquals(2, $task['swimlane_id']);
+ $this->assertEquals(5, $task['column_id']);
+ $this->assertEquals(1, $task['position']);
+ $this->assertEquals(2, $task['project_id']);
+ $this->assertEquals('test', $task['title']);
+ }
+
+ public function testDuplicateAnotherProjectWithoutSwimlane()
+ {
+ $td = new TaskDuplication($this->container);
+ $tc = new TaskCreation($this->container);
+ $tf = new TaskFinder($this->container);
+ $p = new Project($this->container);
+ $s = new Swimlane($this->container);
+
+ // We create 2 projects
+ $this->assertEquals(1, $p->create(array('name' => 'test1')));
+ $this->assertEquals(2, $p->create(array('name' => 'test2')));
+
+ $this->assertNotFalse($s->create(1, 'Swimlane #1'));
+ $this->assertNotFalse($s->create(2, 'Swimlane #2'));
+
+ // We create a task
+ $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 2, 'swimlane_id' => 1)));
+
+ // We duplicate our task to the 2nd project
+ $this->assertEquals(2, $td->duplicateToProject(1, 2));
+ $this->assertTrue($this->container['event']->isEventTriggered(Task::EVENT_CREATE));
+ $this->assertTrue($this->container['event']->isEventTriggered(Task::EVENT_CREATE_UPDATE));
+
+ // Check the values of the duplicated task
+ $task = $tf->getById(2);
+ $this->assertNotEmpty($task);
+ $this->assertEquals(0, $task['owner_id']);
+ $this->assertEquals(0, $task['category_id']);
+ $this->assertEquals(0, $task['swimlane_id']);
$this->assertEquals(5, $task['column_id']);
$this->assertEquals(1, $task['position']);
$this->assertEquals(2, $task['project_id']);
@@ -215,6 +289,7 @@ class TaskDuplicationTest extends Base
$this->assertNotEmpty($task);
$this->assertEquals(1, $task['owner_id']);
$this->assertEquals(0, $task['category_id']);
+ $this->assertEquals(0, $task['swimlane_id']);
$this->assertEquals(2, $task['project_id']);
$this->assertEquals(5, $task['column_id']);
$this->assertEquals(1, $task['position']);
@@ -249,6 +324,7 @@ class TaskDuplicationTest 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(5, $task['column_id']);
$this->assertEquals(1, $task['position']);
$this->assertEquals(2, $task['project_id']);
@@ -324,4 +400,70 @@ class TaskDuplicationTest extends Base
$this->assertEquals(2, $task['project_id']);
$this->assertEquals(5, $task['column_id']);
}
+
+ public function testMoveAnotherProjectWithSwimlane()
+ {
+ $td = new TaskDuplication($this->container);
+ $tc = new TaskCreation($this->container);
+ $tf = new TaskFinder($this->container);
+ $p = new Project($this->container);
+ $s = new Swimlane($this->container);
+
+ // We create 2 projects
+ $this->assertEquals(1, $p->create(array('name' => 'test1')));
+ $this->assertEquals(2, $p->create(array('name' => 'test2')));
+
+ $this->assertNotFalse($s->create(1, 'Swimlane #1'));
+ $this->assertNotFalse($s->create(2, 'Swimlane #1'));
+
+ // We create a task
+ $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 2, 'swimlane_id' => 1)));
+
+ // We move our task to the 2nd project
+ $this->assertTrue($td->moveToProject(1, 2));
+
+ // Check the values of the moved task
+ $task = $tf->getById(1);
+ $this->assertNotEmpty($task);
+ $this->assertEquals(0, $task['owner_id']);
+ $this->assertEquals(0, $task['category_id']);
+ $this->assertEquals(2, $task['swimlane_id']);
+ $this->assertEquals(5, $task['column_id']);
+ $this->assertEquals(1, $task['position']);
+ $this->assertEquals(2, $task['project_id']);
+ $this->assertEquals('test', $task['title']);
+ }
+
+ public function testMoveAnotherProjectWithoutSwimlane()
+ {
+ $td = new TaskDuplication($this->container);
+ $tc = new TaskCreation($this->container);
+ $tf = new TaskFinder($this->container);
+ $p = new Project($this->container);
+ $s = new Swimlane($this->container);
+
+ // We create 2 projects
+ $this->assertEquals(1, $p->create(array('name' => 'test1')));
+ $this->assertEquals(2, $p->create(array('name' => 'test2')));
+
+ $this->assertNotFalse($s->create(1, 'Swimlane #1'));
+ $this->assertNotFalse($s->create(2, 'Swimlane #2'));
+
+ // We create a task
+ $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 2, 'swimlane_id' => 1)));
+
+ // We move our task to the 2nd project
+ $this->assertTrue($td->moveToProject(1, 2));
+
+ // Check the values of the moved task
+ $task = $tf->getById(1);
+ $this->assertNotEmpty($task);
+ $this->assertEquals(0, $task['owner_id']);
+ $this->assertEquals(0, $task['category_id']);
+ $this->assertEquals(0, $task['swimlane_id']);
+ $this->assertEquals(5, $task['column_id']);
+ $this->assertEquals(1, $task['position']);
+ $this->assertEquals(2, $task['project_id']);
+ $this->assertEquals('test', $task['title']);
+ }
}
diff --git a/tests/units/TaskPositionTest.php b/tests/units/TaskPositionTest.php
index 3285bfae..dbc6c74b 100644
--- a/tests/units/TaskPositionTest.php
+++ b/tests/units/TaskPositionTest.php
@@ -7,6 +7,7 @@ use Model\TaskPosition;
use Model\TaskCreation;
use Model\TaskFinder;
use Model\Project;
+use Model\Swimlane;
class TaskPositionTest extends Base
{
@@ -202,7 +203,7 @@ class TaskPositionTest extends Base
$this->assertEquals(3, $tc->create(array('title' => 'Task #3', 'project_id' => 1, 'column_id' => 1)));
$this->assertEquals(4, $tc->create(array('title' => 'Task #4', 'project_id' => 1, 'column_id' => 1)));
- // Move the last task to hte top
+ // Move the last task to the bottom
$this->assertTrue($tp->movePosition(1, 1, 1, 4));
// Check tasks position
@@ -383,14 +384,88 @@ class TaskPositionTest extends Base
$this->assertEquals($task_per_column + 1, $tf->countByColumnId(1, 4));
}
+ public function testMoveTaskSwimlane()
+ {
+ $tp = new TaskPosition($this->container);
+ $tc = new TaskCreation($this->container);
+ $tf = new TaskFinder($this->container);
+ $p = new Project($this->container);
+ $s = new Swimlane($this->container);
+
+ $this->assertEquals(1, $p->create(array('name' => 'Project #1')));
+ $this->assertEquals(1, $s->create(1, 'test 1'));
+ $this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1, 'column_id' => 1)));
+ $this->assertEquals(2, $tc->create(array('title' => 'Task #2', 'project_id' => 1, 'column_id' => 1)));
+ $this->assertEquals(3, $tc->create(array('title' => 'Task #3', 'project_id' => 1, 'column_id' => 1)));
+ $this->assertEquals(4, $tc->create(array('title' => 'Task #4', 'project_id' => 1, 'column_id' => 1)));
+
+ // Move the task to the swimlane
+ $this->assertTrue($tp->movePosition(1, 1, 2, 1, 1));
+
+ // Check tasks position
+ $task = $tf->getById(1);
+ $this->assertEquals(1, $task['id']);
+ $this->assertEquals(2, $task['column_id']);
+ $this->assertEquals(1, $task['position']);
+ $this->assertEquals(1, $task['swimlane_id']);
+
+ $task = $tf->getById(2);
+ $this->assertEquals(2, $task['id']);
+ $this->assertEquals(1, $task['column_id']);
+ $this->assertEquals(1, $task['position']);
+ $this->assertEquals(0, $task['swimlane_id']);
+
+ $task = $tf->getById(3);
+ $this->assertEquals(3, $task['id']);
+ $this->assertEquals(1, $task['column_id']);
+ $this->assertEquals(2, $task['position']);
+ $this->assertEquals(0, $task['swimlane_id']);
+
+ $task = $tf->getById(4);
+ $this->assertEquals(4, $task['id']);
+ $this->assertEquals(1, $task['column_id']);
+ $this->assertEquals(3, $task['position']);
+ $this->assertEquals(0, $task['swimlane_id']);
+
+ // Move the task to the swimlane
+ $this->assertTrue($tp->movePosition(1, 2, 2, 1, 1));
+
+ // Check tasks position
+ $task = $tf->getById(1);
+ $this->assertEquals(1, $task['id']);
+ $this->assertEquals(2, $task['column_id']);
+ $this->assertEquals(2, $task['position']);
+ $this->assertEquals(1, $task['swimlane_id']);
+
+ $task = $tf->getById(2);
+ $this->assertEquals(2, $task['id']);
+ $this->assertEquals(2, $task['column_id']);
+ $this->assertEquals(1, $task['position']);
+ $this->assertEquals(1, $task['swimlane_id']);
+
+ $task = $tf->getById(3);
+ $this->assertEquals(3, $task['id']);
+ $this->assertEquals(1, $task['column_id']);
+ $this->assertEquals(1, $task['position']);
+ $this->assertEquals(0, $task['swimlane_id']);
+
+ $task = $tf->getById(4);
+ $this->assertEquals(4, $task['id']);
+ $this->assertEquals(1, $task['column_id']);
+ $this->assertEquals(2, $task['position']);
+ $this->assertEquals(0, $task['swimlane_id']);
+ }
+
public function testEvents()
{
$tp = new TaskPosition($this->container);
$tc = new TaskCreation($this->container);
$tf = new TaskFinder($this->container);
$p = new Project($this->container);
+ $s = new Swimlane($this->container);
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
+ $this->assertEquals(1, $s->create(1, 'test 1'));
$this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1, 'column_id' => 1)));
$this->assertEquals(2, $tc->create(array('title' => 'Task #2', 'project_id' => 1, 'column_id' => 2)));
@@ -408,6 +483,7 @@ class TaskPositionTest extends Base
$this->assertEquals(2, $task['column_id']);
$this->assertEquals(2, $task['position']);
+ $this->assertFalse($this->container['event']->isEventTriggered(Task::EVENT_MOVE_SWIMLANE));
$this->assertTrue($this->container['event']->isEventTriggered(Task::EVENT_MOVE_COLUMN));
$this->assertFalse($this->container['event']->isEventTriggered(Task::EVENT_MOVE_POSITION));
@@ -433,6 +509,7 @@ class TaskPositionTest extends Base
$this->assertEquals(2, $task['column_id']);
$this->assertEquals(1, $task['position']);
+ $this->assertFalse($this->container['event']->isEventTriggered(Task::EVENT_MOVE_SWIMLANE));
$this->assertFalse($this->container['event']->isEventTriggered(Task::EVENT_MOVE_COLUMN));
$this->assertTrue($this->container['event']->isEventTriggered(Task::EVENT_MOVE_POSITION));
@@ -442,5 +519,34 @@ class TaskPositionTest extends Base
$this->assertEquals(2, $event_data['position']);
$this->assertEquals(2, $event_data['column_id']);
$this->assertEquals(1, $event_data['project_id']);
+
+ $this->container['event']->clearTriggeredEvents();
+
+ // Move to another swimlane
+ $this->assertTrue($tp->movePosition(1, 1, 3, 1, 1));
+
+ $task = $tf->getById(1);
+ $this->assertEquals(1, $task['id']);
+ $this->assertEquals(3, $task['column_id']);
+ $this->assertEquals(1, $task['position']);
+ $this->assertEquals(1, $task['swimlane_id']);
+
+ $task = $tf->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->assertTrue($this->container['event']->isEventTriggered(Task::EVENT_MOVE_SWIMLANE));
+ $this->assertFalse($this->container['event']->isEventTriggered(Task::EVENT_MOVE_POSITION));
+ $this->assertFalse($this->container['event']->isEventTriggered(Task::EVENT_MOVE_POSITION));
+
+ $event_data = $this->container['event']->getEventData(Task::EVENT_MOVE_SWIMLANE);
+ $this->assertNotEmpty($event_data);
+ $this->assertEquals(1, $event_data['task_id']);
+ $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']);
}
}