summaryrefslogtreecommitdiff
path: root/tests/units/Model/ColumnTest.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-02-20 11:24:43 -0500
committerFrederic Guillot <fred@kanboard.net>2016-02-20 11:24:43 -0500
commitc8c1242c26a11dc2abc7126829d76430612e7107 (patch)
tree012c7cf8df996b3af570120cfbfc3dd75eb5a13d /tests/units/Model/ColumnTest.php
parent2d27c36a71f08bea60a992b051bfb8a2d8bd06b6 (diff)
Add drag and drop to change column positions
Diffstat (limited to 'tests/units/Model/ColumnTest.php')
-rw-r--r--tests/units/Model/ColumnTest.php68
1 files changed, 68 insertions, 0 deletions
diff --git a/tests/units/Model/ColumnTest.php b/tests/units/Model/ColumnTest.php
new file mode 100644
index 00000000..a03c3717
--- /dev/null
+++ b/tests/units/Model/ColumnTest.php
@@ -0,0 +1,68 @@
+<?php
+
+require_once __DIR__.'/../Base.php';
+
+use Kanboard\Model\Project;
+use Kanboard\Model\Column;
+
+class ColumnTest extends Base
+{
+ public function testChangePosition()
+ {
+ $projectModel = new Project($this->container);
+ $columnModel = new Column($this->container);
+
+ $this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
+
+ $columns = $columnModel->getAll(1);
+ $this->assertEquals(1, $columns[0]['position']);
+ $this->assertEquals(1, $columns[0]['id']);
+ $this->assertEquals(2, $columns[1]['position']);
+ $this->assertEquals(2, $columns[1]['id']);
+ $this->assertEquals(3, $columns[2]['position']);
+ $this->assertEquals(3, $columns[2]['id']);
+
+ $this->assertTrue($columnModel->changePosition(1, 3, 2));
+
+ $columns = $columnModel->getAll(1);
+ $this->assertEquals(1, $columns[0]['position']);
+ $this->assertEquals(1, $columns[0]['id']);
+ $this->assertEquals(2, $columns[1]['position']);
+ $this->assertEquals(3, $columns[1]['id']);
+ $this->assertEquals(3, $columns[2]['position']);
+ $this->assertEquals(2, $columns[2]['id']);
+
+ $this->assertTrue($columnModel->changePosition(1, 2, 1));
+
+ $columns = $columnModel->getAll(1);
+ $this->assertEquals(1, $columns[0]['position']);
+ $this->assertEquals(2, $columns[0]['id']);
+ $this->assertEquals(2, $columns[1]['position']);
+ $this->assertEquals(1, $columns[1]['id']);
+ $this->assertEquals(3, $columns[2]['position']);
+ $this->assertEquals(3, $columns[2]['id']);
+
+ $this->assertTrue($columnModel->changePosition(1, 2, 2));
+
+ $columns = $columnModel->getAll(1);
+ $this->assertEquals(1, $columns[0]['position']);
+ $this->assertEquals(1, $columns[0]['id']);
+ $this->assertEquals(2, $columns[1]['position']);
+ $this->assertEquals(2, $columns[1]['id']);
+ $this->assertEquals(3, $columns[2]['position']);
+ $this->assertEquals(3, $columns[2]['id']);
+
+ $this->assertTrue($columnModel->changePosition(1, 4, 1));
+
+ $columns = $columnModel->getAll(1);
+ $this->assertEquals(1, $columns[0]['position']);
+ $this->assertEquals(4, $columns[0]['id']);
+ $this->assertEquals(2, $columns[1]['position']);
+ $this->assertEquals(1, $columns[1]['id']);
+ $this->assertEquals(3, $columns[2]['position']);
+ $this->assertEquals(2, $columns[2]['id']);
+
+ $this->assertFalse($columnModel->changePosition(1, 2, 0));
+ $this->assertFalse($columnModel->changePosition(1, 2, 5));
+ }
+}