public function testGetTaskProgression()
 {
     $t = new Task($this->container);
     $ts = new TaskStatus($this->container);
     $tp = new TaskPosition($this->container);
     $tc = new TaskCreation($this->container);
     $tf = new TaskFinder($this->container);
     $p = new Project($this->container);
     $b = new Board($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->assertTrue($tp->movePosition(1, 1, 2, 1));
     $this->assertEquals(25, $t->getProgress($tf->getById(1), $b->getColumnsList(1)));
     $this->assertTrue($tp->movePosition(1, 1, 3, 1));
     $this->assertEquals(50, $t->getProgress($tf->getById(1), $b->getColumnsList(1)));
     $this->assertTrue($tp->movePosition(1, 1, 4, 1));
     $this->assertEquals(75, $t->getProgress($tf->getById(1), $b->getColumnsList(1)));
     $this->assertTrue($ts->close(1));
     $this->assertEquals(100, $t->getProgress($tf->getById(1), $b->getColumnsList(1)));
 }
Ejemplo n.º 2
0
 public function testDuplicateWithColumnParameterNotfound()
 {
     $projectModel = new Project($this->container);
     $actionModel = new Action($this->container);
     $boardModel = new Board($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->assertEquals(1, $actionModel->create(array('project_id' => 1, 'event_name' => Task::EVENT_CREATE, 'action_name' => '\\Kanboard\\Action\\TaskAssignColorColumn', 'params' => array('column_id' => 1, 'color_id' => 'red'))));
     $this->assertEquals(2, $actionModel->create(array('project_id' => 1, 'event_name' => Task::EVENT_MOVE_COLUMN, 'action_name' => '\\Kanboard\\Action\\TaskAssignColorColumn', 'params' => array('column_id' => 2, 'color_id' => 'green'))));
     $this->assertTrue($actionModel->duplicate(1, 2));
     $actions = $actionModel->getAllByProject(2);
     $this->assertCount(1, $actions);
     $this->assertEquals(2, $actions[0]['project_id']);
     $this->assertEquals('\\Kanboard\\Action\\TaskAssignColorColumn', $actions[0]['action_name']);
     $this->assertEquals(Task::EVENT_CREATE, $actions[0]['event_name']);
     $this->assertEquals(array('column_id' => 5, 'color_id' => 'red'), $actions[0]['params']);
 }
Ejemplo n.º 3
0
 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']);
 }
Ejemplo n.º 4
0
 public function testGetBoardWithSwimlane()
 {
     $b = new Board($this->container);
     $tc = new TaskCreation($this->container);
     $tf = new TaskFinder($this->container);
     $p = new Project($this->container);
     $s = new Swimlane($this->container);
     $this->assertEquals(1, $p->create(array('name' => 'Project #1')));
     $this->assertEquals(1, $s->create(array('project_id' => 1, 'name' => 'test 1')));
     $this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1, 'column_id' => 1)));
     $this->assertEquals(2, $tc->create(array('title' => 'Task #2', 'project_id' => 1, 'column_id' => 3)));
     $this->assertEquals(3, $tc->create(array('title' => 'Task #3', 'project_id' => 1, 'column_id' => 2, 'swimlane_id' => 1)));
     $this->assertEquals(4, $tc->create(array('title' => 'Task #4', 'project_id' => 1, 'column_id' => 3)));
     $this->assertEquals(5, $tc->create(array('title' => 'Task #5', 'project_id' => 1, 'column_id' => 4, 'score' => 2)));
     $this->assertEquals(6, $tc->create(array('title' => 'Task #6', 'project_id' => 1, 'column_id' => 4, 'score' => 3, 'swimlane_id' => 1)));
     $board = $b->getBoard(1);
     $this->assertNotEmpty($board);
     $this->assertEquals(2, count($board));
     $this->assertEquals(6, count($board[0]));
     $this->assertArrayHasKey('name', $board[0]);
     $this->assertArrayHasKey('nb_tasks', $board[0]);
     $this->assertArrayHasKey('columns', $board[0]);
     $this->assertArrayHasKey('tasks', $board[0]['columns'][2]);
     $this->assertArrayHasKey('nb_tasks', $board[0]['columns'][2]);
     $this->assertArrayHasKey('title', $board[0]['columns'][2]);
     $this->assertArrayHasKey('nb_column_tasks', $board[0]['columns'][0]);
     $this->assertArrayNotHasKey('nb_column_tasks', $board[1]['columns'][0]);
     $this->assertArrayNotHasKey('total_score', $board[1]['columns'][0]);
     $this->assertArrayHasKey('score', $board[0]['columns'][3]);
     $this->assertArrayHasKey('total_score', $board[0]['columns'][3]);
     $this->assertEquals(2, $board[0]['columns'][3]['score']);
     $this->assertEquals(5, $board[0]['columns'][3]['total_score']);
     $task = $tf->getById(1);
     $this->assertEquals(1, $task['id']);
     $this->assertEquals(1, $task['column_id']);
     $this->assertEquals(1, $task['position']);
     $this->assertEquals(0, $task['swimlane_id']);
     $this->assertEquals(1, $board[0]['columns'][0]['tasks'][0]['id']);
     $this->assertEquals(1, $board[0]['columns'][0]['tasks'][0]['column_id']);
     $this->assertEquals(1, $board[0]['columns'][0]['tasks'][0]['position']);
     $this->assertEquals(0, $board[0]['columns'][0]['tasks'][0]['swimlane_id']);
     $task = $tf->getById(2);
     $this->assertEquals(2, $task['id']);
     $this->assertEquals(3, $task['column_id']);
     $this->assertEquals(1, $task['position']);
     $this->assertEquals(0, $task['swimlane_id']);
     $this->assertEquals(2, $board[0]['columns'][2]['tasks'][0]['id']);
     $this->assertEquals(3, $board[0]['columns'][2]['tasks'][0]['column_id']);
     $this->assertEquals(1, $board[0]['columns'][2]['tasks'][0]['position']);
     $this->assertEquals(0, $board[0]['columns'][2]['tasks'][0]['swimlane_id']);
     $task = $tf->getById(3);
     $this->assertEquals(3, $task['id']);
     $this->assertEquals(2, $task['column_id']);
     $this->assertEquals(1, $task['position']);
     $this->assertEquals(1, $task['swimlane_id']);
     $this->assertEquals(3, $board[1]['columns'][1]['tasks'][0]['id']);
     $this->assertEquals(2, $board[1]['columns'][1]['tasks'][0]['column_id']);
     $this->assertEquals(1, $board[1]['columns'][1]['tasks'][0]['position']);
     $this->assertEquals(1, $board[1]['columns'][1]['tasks'][0]['swimlane_id']);
     $task = $tf->getById(4);
     $this->assertEquals(4, $task['id']);
     $this->assertEquals(3, $task['column_id']);
     $this->assertEquals(2, $task['position']);
     $this->assertEquals(0, $task['swimlane_id']);
     $this->assertEquals(4, $board[0]['columns'][2]['tasks'][1]['id']);
     $this->assertEquals(3, $board[0]['columns'][2]['tasks'][1]['column_id']);
     $this->assertEquals(2, $board[0]['columns'][2]['tasks'][1]['position']);
     $this->assertEquals(0, $board[0]['columns'][2]['tasks'][1]['swimlane_id']);
     $task = $tf->getById(5);
     $this->assertEquals(5, $task['id']);
     $this->assertEquals(4, $task['column_id']);
     $this->assertEquals(1, $task['position']);
     $this->assertEquals(0, $task['swimlane_id']);
     $this->assertEquals(5, $board[0]['columns'][3]['tasks'][0]['id']);
     $this->assertEquals(4, $board[0]['columns'][3]['tasks'][0]['column_id']);
     $this->assertEquals(1, $board[0]['columns'][3]['tasks'][0]['position']);
     $this->assertEquals(0, $board[0]['columns'][3]['tasks'][0]['swimlane_id']);
     $task = $tf->getById(6);
     $this->assertEquals(6, $task['id']);
     $this->assertEquals(4, $task['column_id']);
     $this->assertEquals(1, $task['position']);
     $this->assertEquals(1, $task['swimlane_id']);
     $this->assertEquals(6, $board[1]['columns'][3]['tasks'][0]['id']);
     $this->assertEquals(4, $board[1]['columns'][3]['tasks'][0]['column_id']);
     $this->assertEquals(1, $board[1]['columns'][3]['tasks'][0]['position']);
     $this->assertEquals(1, $board[1]['columns'][3]['tasks'][0]['swimlane_id']);
 }