summaryrefslogtreecommitdiff
path: root/tests/units/BoardTest.php
diff options
context:
space:
mode:
authorFrédéric Guillot <fred@kanboard.net>2014-06-20 15:41:05 -0300
committerFrédéric Guillot <fred@kanboard.net>2014-06-20 15:41:05 -0300
commit7c5b900bd83b6b9bdb5656eb169381ff46f8106a (patch)
tree39481ff2ee73d7479369655ba86d343f302e1499 /tests/units/BoardTest.php
parentefdc959c555872677e599d2ff12e1263d719f3f2 (diff)
First API implementation
Diffstat (limited to 'tests/units/BoardTest.php')
-rw-r--r--tests/units/BoardTest.php77
1 files changed, 77 insertions, 0 deletions
diff --git a/tests/units/BoardTest.php b/tests/units/BoardTest.php
new file mode 100644
index 00000000..d5686b3f
--- /dev/null
+++ b/tests/units/BoardTest.php
@@ -0,0 +1,77 @@
+<?php
+
+require_once __DIR__.'/Base.php';
+
+use Model\Project;
+use Model\Board;
+
+class BoardTest extends Base
+{
+ public function testMoveColumns()
+ {
+ $p = new Project($this->db, $this->event);
+ $b = new Board($this->db, $this->event);
+
+ // We create 2 projects
+ $this->assertEquals(1, $p->create(array('name' => 'UnitTest1')));
+ $this->assertEquals(2, $p->create(array('name' => 'UnitTest2')));
+
+ // We get the columns of the project 2
+ $columns = $b->getColumns(2);
+ $columns_id = array_keys($b->getColumnsList(2));
+ $this->assertNotEmpty($columns);
+
+ // Initial order: 5, 6, 7, 8
+
+ // Move the column 1 down
+ $this->assertEquals(1, $columns[0]['position']);
+ $this->assertEquals($columns_id[0], $columns[0]['id']);
+
+ $this->assertEquals(2, $columns[1]['position']);
+ $this->assertEquals($columns_id[1], $columns[1]['id']);
+
+ $this->assertTrue($b->moveDown(2, $columns[0]['id']));
+ $columns = $b->getColumns(2); // Sorted by position
+
+ // New order: 6, 5, 7, 8
+
+ $this->assertEquals(1, $columns[0]['position']);
+ $this->assertEquals($columns_id[1], $columns[0]['id']);
+
+ $this->assertEquals(2, $columns[1]['position']);
+ $this->assertEquals($columns_id[0], $columns[1]['id']);
+
+ // Move the column 3 up
+ $this->assertTrue($b->moveUp(2, $columns[2]['id']));
+ $columns = $b->getColumns(2);
+
+ // New order: 6, 7, 5, 8
+
+ $this->assertEquals(1, $columns[0]['position']);
+ $this->assertEquals($columns_id[1], $columns[0]['id']);
+
+ $this->assertEquals(2, $columns[1]['position']);
+ $this->assertEquals($columns_id[2], $columns[1]['id']);
+
+ $this->assertEquals(3, $columns[2]['position']);
+ $this->assertEquals($columns_id[0], $columns[2]['id']);
+
+ // Move column 1 up (must do nothing because it's the first column)
+ $this->assertFalse($b->moveUp(2, $columns[0]['id']));
+ $columns = $b->getColumns(2);
+
+ // Order: 6, 7, 5, 8
+
+ $this->assertEquals(1, $columns[0]['position']);
+ $this->assertEquals($columns_id[1], $columns[0]['id']);
+
+ // Move column 4 down (must do nothing because it's the last column)
+ $this->assertFalse($b->moveDown(2, $columns[3]['id']));
+ $columns = $b->getColumns(2);
+
+ // Order: 6, 7, 5, 8
+
+ $this->assertEquals(4, $columns[3]['position']);
+ $this->assertEquals($columns_id[3], $columns[3]['id']);
+ }
+}