summaryrefslogtreecommitdiff
path: root/tests/BoardTest.php
diff options
context:
space:
mode:
authorFrédéric Guillot <fguillot@users.noreply.github.com>2014-03-16 10:44:05 -0400
committerFrédéric Guillot <fguillot@users.noreply.github.com>2014-03-16 10:44:05 -0400
commite0a5045ed5f3a4a6a34d252f5251295a27d11418 (patch)
treefb9affe5aab371e64ceb6403818d6acd99203b97 /tests/BoardTest.php
parent395a8a5f2a4976b80432a0d71d51d1bad3d01a83 (diff)
Add the possiblity to reorder the column position for a board
Diffstat (limited to 'tests/BoardTest.php')
-rw-r--r--tests/BoardTest.php77
1 files changed, 77 insertions, 0 deletions
diff --git a/tests/BoardTest.php b/tests/BoardTest.php
new file mode 100644
index 00000000..c29b2d0c
--- /dev/null
+++ b/tests/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']);
+ }
+}