summaryrefslogtreecommitdiff
path: root/tests/units/TaskPositionTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/units/TaskPositionTest.php')
-rw-r--r--tests/units/TaskPositionTest.php108
1 files changed, 107 insertions, 1 deletions
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']);
}
}