summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-04-18 15:10:40 -0400
committerFrederic Guillot <fred@kanboard.net>2015-04-18 15:10:40 -0400
commit54449d48c45b87699a796ca71b42c42a95dd9b8d (patch)
tree54203609ffa90ff9a942e50478bceeba42df7acc /tests
parent7b7ea56460f755e77194b969c40a38c557ed08f6 (diff)
Fix bug when moving subtasks with non consecutive positions
Diffstat (limited to 'tests')
-rw-r--r--tests/units/SubtaskTest.php39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/units/SubtaskTest.php b/tests/units/SubtaskTest.php
index eb1a3fd3..791f8089 100644
--- a/tests/units/SubtaskTest.php
+++ b/tests/units/SubtaskTest.php
@@ -24,6 +24,7 @@ class SubTaskTest extends Base
$this->assertEquals(2, $s->create(array('title' => 'subtask #2', 'task_id' => 1)));
$this->assertEquals(3, $s->create(array('title' => 'subtask #3', 'task_id' => 1)));
+ // Check positions
$subtask = $s->getById(1);
$this->assertNotEmpty($subtask);
$this->assertEquals(1, $subtask['position']);
@@ -36,8 +37,10 @@ class SubTaskTest extends Base
$this->assertNotEmpty($subtask);
$this->assertEquals(3, $subtask['position']);
+ // Move up
$this->assertTrue($s->moveUp(1, 2));
+ // Check positions
$subtask = $s->getById(1);
$this->assertNotEmpty($subtask);
$this->assertEquals(2, $subtask['position']);
@@ -50,7 +53,24 @@ class SubTaskTest extends Base
$this->assertNotEmpty($subtask);
$this->assertEquals(3, $subtask['position']);
+ // We can't move up #2
$this->assertFalse($s->moveUp(1, 2));
+
+ // Test remove
+ $this->assertTrue($s->remove(1));
+ $this->assertTrue($s->moveUp(1, 3));
+
+ // Check positions
+ $subtask = $s->getById(1);
+ $this->assertEmpty($subtask);
+
+ $subtask = $s->getById(2);
+ $this->assertNotEmpty($subtask);
+ $this->assertEquals(2, $subtask['position']);
+
+ $subtask = $s->getById(3);
+ $this->assertNotEmpty($subtask);
+ $this->assertEquals(1, $subtask['position']);
}
public function testMoveDown()
@@ -66,8 +86,10 @@ class SubTaskTest extends Base
$this->assertEquals(2, $s->create(array('title' => 'subtask #2', 'task_id' => 1)));
$this->assertEquals(3, $s->create(array('title' => 'subtask #3', 'task_id' => 1)));
+ // Move down #1
$this->assertTrue($s->moveDown(1, 1));
+ // Check positions
$subtask = $s->getById(1);
$this->assertNotEmpty($subtask);
$this->assertEquals(2, $subtask['position']);
@@ -80,7 +102,24 @@ class SubTaskTest extends Base
$this->assertNotEmpty($subtask);
$this->assertEquals(3, $subtask['position']);
+ // We can't move down #3
$this->assertFalse($s->moveDown(1, 3));
+
+ // Test remove
+ $this->assertTrue($s->remove(1));
+ $this->assertTrue($s->moveDown(1, 2));
+
+ // Check positions
+ $subtask = $s->getById(1);
+ $this->assertEmpty($subtask);
+
+ $subtask = $s->getById(2);
+ $this->assertNotEmpty($subtask);
+ $this->assertEquals(2, $subtask['position']);
+
+ $subtask = $s->getById(3);
+ $this->assertNotEmpty($subtask);
+ $this->assertEquals(1, $subtask['position']);
}
public function testDuplicate()