diff options
Diffstat (limited to 'tests/units')
-rw-r--r-- | tests/units/Model/ActionTest.php | 6 | ||||
-rw-r--r-- | tests/units/Model/BoardTest.php | 227 | ||||
-rw-r--r-- | tests/units/Model/ColumnTest.php | 168 | ||||
-rw-r--r-- | tests/units/Model/ProjectTest.php | 2 | ||||
-rw-r--r-- | tests/units/Model/TaskPositionTest.php | 14 |
5 files changed, 182 insertions, 235 deletions
diff --git a/tests/units/Model/ActionTest.php b/tests/units/Model/ActionTest.php index 8d574115..ed687846 100644 --- a/tests/units/Model/ActionTest.php +++ b/tests/units/Model/ActionTest.php @@ -6,7 +6,7 @@ use Kanboard\Model\Action; use Kanboard\Model\Project; use Kanboard\Model\Task; use Kanboard\Model\User; -use Kanboard\Model\Board; +use Kanboard\Model\Column; use Kanboard\Model\Category; use Kanboard\Model\ProjectUserRole; use Kanboard\Core\Security\Role; @@ -260,12 +260,12 @@ class ActionTest extends Base { $projectModel = new Project($this->container); $actionModel = new Action($this->container); - $boardModel = new Board($this->container); + $columnModel = new Column($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); $this->assertEquals(2, $projectModel->create(array('name' => 'test2'))); - $this->assertTrue($boardModel->updateColumn(2, 'My unique column')); + $this->assertTrue($columnModel->update(2, 'My unique column')); $this->assertEquals(1, $actionModel->create(array( 'project_id' => 1, diff --git a/tests/units/Model/BoardTest.php b/tests/units/Model/BoardTest.php index bb6c4b76..bb0778ce 100644 --- a/tests/units/Model/BoardTest.php +++ b/tests/units/Model/BoardTest.php @@ -4,6 +4,7 @@ require_once __DIR__.'/../Base.php'; use Kanboard\Model\Project; use Kanboard\Model\Board; +use Kanboard\Model\Column; use Kanboard\Model\Config; use Kanboard\Model\TaskCreation; use Kanboard\Model\TaskFinder; @@ -15,12 +16,13 @@ class BoardTest extends Base { $p = new Project($this->container); $b = new Board($this->container); + $columnModel = new Column($this->container); $c = new Config($this->container); // Default columns $this->assertEquals(1, $p->create(array('name' => 'UnitTest1'))); - $columns = $b->getColumnsList(1); + $columns = $columnModel->getList(1); $this->assertTrue(is_array($columns)); $this->assertEquals(4, count($columns)); @@ -37,7 +39,7 @@ class BoardTest extends Base $this->assertEquals($input, $c->get('board_columns')); $this->assertEquals(2, $p->create(array('name' => 'UnitTest2'))); - $columns = $b->getColumnsList(2); + $columns = $columnModel->getList(2); $this->assertTrue(is_array($columns)); $this->assertEquals(2, count($columns)); @@ -161,225 +163,4 @@ class BoardTest extends Base $this->assertEquals(1, $board[1]['columns'][3]['tasks'][0]['position']); $this->assertEquals(1, $board[1]['columns'][3]['tasks'][0]['swimlane_id']); } - - public function testGetColumn() - { - $p = new Project($this->container); - $b = new Board($this->container); - - $this->assertEquals(1, $p->create(array('name' => 'UnitTest1'))); - - $column = $b->getColumn(3); - $this->assertNotEmpty($column); - $this->assertEquals('Work in progress', $column['title']); - - $column = $b->getColumn(33); - $this->assertEmpty($column); - } - - public function testRemoveColumn() - { - $p = new Project($this->container); - $b = new Board($this->container); - - $this->assertEquals(1, $p->create(array('name' => 'UnitTest1'))); - $this->assertTrue($b->removeColumn(3)); - $this->assertFalse($b->removeColumn(322)); - - $columns = $b->getColumns(1); - $this->assertTrue(is_array($columns)); - $this->assertEquals(3, count($columns)); - } - - public function testUpdateColumn() - { - $p = new Project($this->container); - $b = new Board($this->container); - - $this->assertEquals(1, $p->create(array('name' => 'UnitTest1'))); - - $this->assertTrue($b->updateColumn(3, 'blah', 5)); - $this->assertTrue($b->updateColumn(2, 'boo')); - - $column = $b->getColumn(3); - $this->assertNotEmpty($column); - $this->assertEquals('blah', $column['title']); - $this->assertEquals(5, $column['task_limit']); - - $column = $b->getColumn(2); - $this->assertNotEmpty($column); - $this->assertEquals('boo', $column['title']); - $this->assertEquals(0, $column['task_limit']); - } - - public function testAddColumn() - { - $p = new Project($this->container); - $b = new Board($this->container); - - $this->assertEquals(1, $p->create(array('name' => 'UnitTest1'))); - $this->assertNotFalse($b->addColumn(1, 'another column')); - $this->assertNotFalse($b->addColumn(1, 'one more', 3, 'one more description')); - - $columns = $b->getColumns(1); - $this->assertTrue(is_array($columns)); - $this->assertEquals(6, count($columns)); - - $this->assertEquals('another column', $columns[4]['title']); - $this->assertEquals(0, $columns[4]['task_limit']); - $this->assertEquals(5, $columns[4]['position']); - - $this->assertEquals('one more', $columns[5]['title']); - $this->assertEquals(3, $columns[5]['task_limit']); - $this->assertEquals(6, $columns[5]['position']); - $this->assertEquals('one more description', $columns[5]['description']); - } - - public function testMoveColumns() - { - $p = new Project($this->container); - $b = new Board($this->container); - - // 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']); - } - - public function testMoveUpAndRemoveColumn() - { - $p = new Project($this->container); - $b = new Board($this->container); - - // We create a project - $this->assertEquals(1, $p->create(array('name' => 'UnitTest1'))); - - // We remove the second column - $this->assertTrue($b->removeColumn(2)); - - $columns = $b->getColumns(1); - $this->assertNotEmpty($columns); - $this->assertCount(3, $columns); - - $this->assertEquals(1, $columns[0]['position']); - $this->assertEquals(3, $columns[1]['position']); - $this->assertEquals(4, $columns[2]['position']); - - $this->assertEquals(1, $columns[0]['id']); - $this->assertEquals(3, $columns[1]['id']); - $this->assertEquals(4, $columns[2]['id']); - - // We move up the second column - $this->assertTrue($b->moveUp(1, $columns[1]['id'])); - - // Check the new positions - $columns = $b->getColumns(1); - $this->assertNotEmpty($columns); - $this->assertCount(3, $columns); - - $this->assertEquals(1, $columns[0]['position']); - $this->assertEquals(2, $columns[1]['position']); - $this->assertEquals(3, $columns[2]['position']); - - $this->assertEquals(3, $columns[0]['id']); - $this->assertEquals(1, $columns[1]['id']); - $this->assertEquals(4, $columns[2]['id']); - } - - public function testMoveDownAndRemoveColumn() - { - $p = new Project($this->container); - $b = new Board($this->container); - - // We create a project - $this->assertEquals(1, $p->create(array('name' => 'UnitTest1'))); - - // We remove the second column - $this->assertTrue($b->removeColumn(2)); - - $columns = $b->getColumns(1); - $this->assertNotEmpty($columns); - $this->assertCount(3, $columns); - - $this->assertEquals(1, $columns[0]['position']); - $this->assertEquals(3, $columns[1]['position']); - $this->assertEquals(4, $columns[2]['position']); - - $this->assertEquals(1, $columns[0]['id']); - $this->assertEquals(3, $columns[1]['id']); - $this->assertEquals(4, $columns[2]['id']); - - // We move up the second column - $this->assertTrue($b->moveDown(1, $columns[0]['id'])); - - // Check the new positions - $columns = $b->getColumns(1); - $this->assertNotEmpty($columns); - $this->assertCount(3, $columns); - - $this->assertEquals(1, $columns[0]['position']); - $this->assertEquals(2, $columns[1]['position']); - $this->assertEquals(3, $columns[2]['position']); - - $this->assertEquals(3, $columns[0]['id']); - $this->assertEquals(1, $columns[1]['id']); - $this->assertEquals(4, $columns[2]['id']); - } } diff --git a/tests/units/Model/ColumnTest.php b/tests/units/Model/ColumnTest.php index a03c3717..e40f89c6 100644 --- a/tests/units/Model/ColumnTest.php +++ b/tests/units/Model/ColumnTest.php @@ -7,6 +7,174 @@ use Kanboard\Model\Column; class ColumnTest extends Base { + public function testGetColumn() + { + $projectModel = new Project($this->container); + $columnModel = new Column($this->container); + + $this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest'))); + + $column = $columnModel->getById(3); + $this->assertNotEmpty($column); + $this->assertEquals('Work in progress', $column['title']); + + $column = $columnModel->getById(33); + $this->assertEmpty($column); + } + + public function testGetFirstColumnId() + { + $projectModel = new Project($this->container); + $columnModel = new Column($this->container); + + $this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest'))); + $this->assertEquals(1, $columnModel->getFirstColumnId(1)); + } + + public function testGetLastColumnId() + { + $projectModel = new Project($this->container); + $columnModel = new Column($this->container); + + $this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest'))); + $this->assertEquals(4, $columnModel->getLastColumnId(1)); + } + + public function testGetLastColumnPosition() + { + $projectModel = new Project($this->container); + $columnModel = new Column($this->container); + + $this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest'))); + $this->assertEquals(4, $columnModel->getLastColumnPosition(1)); + } + + public function testGetColumnIdByTitle() + { + $projectModel = new Project($this->container); + $columnModel = new Column($this->container); + + $this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest'))); + $this->assertEquals(2, $columnModel->getColumnIdByTitle(1, 'Ready')); + } + + public function testGetTitleByColumnId() + { + $projectModel = new Project($this->container); + $columnModel = new Column($this->container); + + $this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest'))); + $this->assertEquals('Work in progress', $columnModel->getColumnTitleById(3)); + } + + public function testGetAll() + { + $projectModel = new Project($this->container); + $columnModel = new Column($this->container); + + $this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest'))); + + $columns = $columnModel->getAll(1); + $this->assertCount(4, $columns); + + $this->assertEquals(1, $columns[0]['id']); + $this->assertEquals(1, $columns[0]['position']); + $this->assertEquals('Backlog', $columns[0]['title']); + + $this->assertEquals(2, $columns[1]['id']); + $this->assertEquals(2, $columns[1]['position']); + $this->assertEquals('Ready', $columns[1]['title']); + + $this->assertEquals(3, $columns[2]['id']); + $this->assertEquals(3, $columns[2]['position']); + $this->assertEquals('Work in progress', $columns[2]['title']); + + $this->assertEquals(4, $columns[3]['id']); + $this->assertEquals(4, $columns[3]['position']); + $this->assertEquals('Done', $columns[3]['title']); + } + + public function testGetList() + { + $projectModel = new Project($this->container); + $columnModel = new Column($this->container); + + $this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest'))); + + $columns = $columnModel->getList(1); + $this->assertCount(4, $columns); + $this->assertEquals('Backlog', $columns[1]); + $this->assertEquals('Ready', $columns[2]); + $this->assertEquals('Work in progress', $columns[3]); + $this->assertEquals('Done', $columns[4]); + + $columns = $columnModel->getList(1, true); + $this->assertCount(5, $columns); + $this->assertEquals('All columns', $columns[-1]); + $this->assertEquals('Backlog', $columns[1]); + $this->assertEquals('Ready', $columns[2]); + $this->assertEquals('Work in progress', $columns[3]); + $this->assertEquals('Done', $columns[4]); + } + + public function testAddColumn() + { + $projectModel = new Project($this->container); + $columnModel = new Column($this->container); + + $this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest'))); + $this->assertNotFalse($columnModel->create(1, 'another column')); + $this->assertNotFalse($columnModel->create(1, 'one more', 3, 'one more description')); + + $columns = $columnModel->getAll(1); + $this->assertTrue(is_array($columns)); + $this->assertEquals(6, count($columns)); + + $this->assertEquals('another column', $columns[4]['title']); + $this->assertEquals(0, $columns[4]['task_limit']); + $this->assertEquals(5, $columns[4]['position']); + + $this->assertEquals('one more', $columns[5]['title']); + $this->assertEquals(3, $columns[5]['task_limit']); + $this->assertEquals(6, $columns[5]['position']); + $this->assertEquals('one more description', $columns[5]['description']); + } + + public function testUpdateColumn() + { + $projectModel = new Project($this->container); + $columnModel = new Column($this->container); + + $this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest'))); + + $this->assertTrue($columnModel->update(3, 'blah', 5)); + $this->assertTrue($columnModel->update(2, 'boo')); + + $column = $columnModel->getById(3); + $this->assertNotEmpty($column); + $this->assertEquals('blah', $column['title']); + $this->assertEquals(5, $column['task_limit']); + + $column = $columnModel->getById(2); + $this->assertNotEmpty($column); + $this->assertEquals('boo', $column['title']); + $this->assertEquals(0, $column['task_limit']); + } + + public function testRemoveColumn() + { + $projectModel = new Project($this->container); + $columnModel = new Column($this->container); + + $this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest'))); + $this->assertTrue($columnModel->remove(3)); + $this->assertFalse($columnModel->remove(322)); + + $columns = $columnModel->getAll(1); + $this->assertTrue(is_array($columns)); + $this->assertEquals(3, count($columns)); + } + public function testChangePosition() { $projectModel = new Project($this->container); diff --git a/tests/units/Model/ProjectTest.php b/tests/units/Model/ProjectTest.php index cadb42a6..5478fa40 100644 --- a/tests/units/Model/ProjectTest.php +++ b/tests/units/Model/ProjectTest.php @@ -8,8 +8,6 @@ use Kanboard\Model\Project; use Kanboard\Model\User; use Kanboard\Model\Task; use Kanboard\Model\TaskCreation; -use Kanboard\Model\Acl; -use Kanboard\Model\Board; use Kanboard\Model\Config; use Kanboard\Model\Category; diff --git a/tests/units/Model/TaskPositionTest.php b/tests/units/Model/TaskPositionTest.php index 5f045768..28145a66 100644 --- a/tests/units/Model/TaskPositionTest.php +++ b/tests/units/Model/TaskPositionTest.php @@ -3,7 +3,7 @@ require_once __DIR__.'/../Base.php'; use Kanboard\Model\Task; -use Kanboard\Model\Board; +use Kanboard\Model\Column; use Kanboard\Model\TaskStatus; use Kanboard\Model\TaskPosition; use Kanboard\Model\TaskCreation; @@ -21,23 +21,23 @@ class TaskPositionTest extends Base $tc = new TaskCreation($this->container); $tf = new TaskFinder($this->container); $p = new Project($this->container); - $b = new Board($this->container); + $columnModel = new Column($this->container); $this->assertEquals(1, $p->create(array('name' => 'Project #1'))); $this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1, 'column_id' => 1))); - $this->assertEquals(0, $t->getProgress($tf->getById(1), $b->getColumnsList(1))); + $this->assertEquals(0, $t->getProgress($tf->getById(1), $columnModel->getList(1))); $this->assertTrue($tp->movePosition(1, 1, 2, 1)); - $this->assertEquals(25, $t->getProgress($tf->getById(1), $b->getColumnsList(1))); + $this->assertEquals(25, $t->getProgress($tf->getById(1), $columnModel->getList(1))); $this->assertTrue($tp->movePosition(1, 1, 3, 1)); - $this->assertEquals(50, $t->getProgress($tf->getById(1), $b->getColumnsList(1))); + $this->assertEquals(50, $t->getProgress($tf->getById(1), $columnModel->getList(1))); $this->assertTrue($tp->movePosition(1, 1, 4, 1)); - $this->assertEquals(75, $t->getProgress($tf->getById(1), $b->getColumnsList(1))); + $this->assertEquals(75, $t->getProgress($tf->getById(1), $columnModel->getList(1))); $this->assertTrue($ts->close(1)); - $this->assertEquals(100, $t->getProgress($tf->getById(1), $b->getColumnsList(1))); + $this->assertEquals(100, $t->getProgress($tf->getById(1), $columnModel->getList(1))); } public function testMoveTaskToWrongPosition() |