diff options
Diffstat (limited to 'tests/units/Model/ColumnTest.php')
-rw-r--r-- | tests/units/Model/ColumnTest.php | 68 |
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)); + } +} |