public function testMoveTaskAnotherSwimlane() { $tp = new TaskPosition($this->container); $tc = new TaskCreation($this->container); $p = new Project($this->container); $tf = new TaskFinder($this->container); $s = new Swimlane($this->container); $this->container['dispatcher'] = new EventDispatcher(); $this->container['dispatcher']->addSubscriber(new TaskMovedDateSubscriber($this->container)); $now = time(); $this->assertEquals(1, $p->create(array('name' => 'Project #1'))); $this->assertEquals(1, $s->create(array('project_id' => 1, 'name' => 'S1'))); $this->assertEquals(2, $s->create(array('project_id' => 1, 'name' => 'S2'))); $this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1))); $task = $tf->getById(1); $this->assertNotEmpty($task); $this->assertEquals($now, $task['date_moved'], '', 1); $this->assertEquals(1, $task['column_id']); $this->assertEquals(0, $task['swimlane_id']); sleep(1); $this->assertTrue($tp->movePosition(1, 1, 2, 1, 2)); $task = $tf->getById(1); $this->assertNotEmpty($task); $this->assertNotEquals($now, $task['date_moved']); $this->assertEquals(2, $task['column_id']); $this->assertEquals(2, $task['swimlane_id']); }
public function testExport() { $tc = new TaskCreation($this->container); $p = new Project($this->container); $c = new Category($this->container); $e = new TaskExport($this->container); $s = new Swimlane($this->container); $this->assertEquals(1, $p->create(array('name' => 'Export Project'))); $this->assertEquals(1, $s->create(1, 'S1')); $this->assertEquals(2, $s->create(1, 'S2')); $this->assertNotFalse($c->create(array('name' => 'Category #1', 'project_id' => 1))); $this->assertNotFalse($c->create(array('name' => 'Category #2', 'project_id' => 1))); $this->assertNotFalse($c->create(array('name' => 'Category #3', 'project_id' => 1))); for ($i = 1; $i <= 100; $i++) { $task = array('title' => 'Task #' . $i, 'project_id' => 1, 'column_id' => rand(1, 3), 'creator_id' => rand(0, 1), 'owner_id' => rand(0, 1), 'color_id' => rand(0, 1) === 0 ? 'green' : 'purple', 'category_id' => rand(0, 3), 'date_due' => array_rand(array(0, date('Y-m-d'), date('Y-m-d', strtotime('+' . $i . 'day')))), 'score' => rand(0, 21), 'swimlane_id' => rand(0, 2)); $this->assertEquals($i, $tc->create($task)); } $rows = $e->export(1, strtotime('-1 day'), strtotime('+1 day')); $this->assertEquals($i, count($rows)); $this->assertEquals('Task Id', $rows[0][0]); $this->assertEquals(1, $rows[1][0]); $this->assertEquals('Task #' . ($i - 1), $rows[$i - 1][12]); $this->assertTrue(in_array($rows[$i - 1][4], array('Default swimlane', 'S1', 'S2'))); }
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(1, '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))); $this->assertEquals(6, $tc->create(array('title' => 'Task #6', 'project_id' => 1, 'column_id' => 4, 'swimlane_id' => 1))); $board = $b->getBoard(1); $this->assertNotEmpty($board); $this->assertEquals(2, count($board)); $this->assertEquals(5, count($board[0])); $this->assertTrue(array_key_exists('nb_tasks', $board[0])); $this->assertTrue(array_key_exists('name', $board[0])); $this->assertTrue(array_key_exists('columns', $board[0])); $this->assertTrue(array_key_exists('tasks', $board[0]['columns'][2])); $this->assertTrue(array_key_exists('title', $board[0]['columns'][2])); $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']); }
public function testMoveAnotherProjectWithoutSwimlane() { $td = new TaskDuplication($this->container); $tc = new TaskCreation($this->container); $tf = new TaskFinder($this->container); $p = new Project($this->container); $s = new Swimlane($this->container); // We create 2 projects $this->assertEquals(1, $p->create(array('name' => 'test1'))); $this->assertEquals(2, $p->create(array('name' => 'test2'))); $this->assertNotFalse($s->create(1, 'Swimlane #1')); $this->assertNotFalse($s->create(2, 'Swimlane #2')); // We create a task $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 2, 'swimlane_id' => 1))); // We move our task to the 2nd project $this->assertTrue($td->moveToProject(1, 2)); // Check the values of the moved task $task = $tf->getById(1); $this->assertNotEmpty($task); $this->assertEquals(0, $task['owner_id']); $this->assertEquals(0, $task['category_id']); $this->assertEquals(0, $task['swimlane_id']); $this->assertEquals(5, $task['column_id']); $this->assertEquals(1, $task['position']); $this->assertEquals(2, $task['project_id']); $this->assertEquals('test', $task['title']); }
public function testDuplicateSwimlane() { $p = new Project($this->container); $s = new Swimlane($this->container); $this->assertEquals(1, $p->create(array('name' => 'P1'))); $this->assertEquals(2, $p->create(array('name' => 'P2'))); $this->assertEquals(1, $s->create(array('project_id' => 1, 'name' => 'S1'))); $this->assertEquals(2, $s->create(array('project_id' => 1, 'name' => 'S2'))); $this->assertEquals(3, $s->create(array('project_id' => 1, 'name' => 'S3'))); $default_swimlane1 = $s->getDefault(1); $default_swimlane1['default_swimlane'] = 'New Default'; $this->assertTrue($s->updateDefault($default_swimlane1)); $this->assertTrue($s->duplicate(1, 2)); $swimlanes = $s->getAll(2); $this->assertCount(3, $swimlanes); $this->assertEquals(4, $swimlanes[0]['id']); $this->assertEquals('S1', $swimlanes[0]['name']); $this->assertEquals(5, $swimlanes[1]['id']); $this->assertEquals('S2', $swimlanes[1]['name']); $this->assertEquals(6, $swimlanes[2]['id']); $this->assertEquals('S3', $swimlanes[2]['name']); $new_default = $s->getDefault(2); $this->assertEquals('New Default', $new_default['default_swimlane']); }
public function testSearchWithSwimlane() { $p = new Project($this->container); $tc = new TaskCreation($this->container); $tf = new TaskFilter($this->container); $s = new Swimlane($this->container); $this->assertEquals(1, $p->create(array('name' => 'My project A'))); $this->assertEquals(1, $s->create(array('project_id' => 1, 'name' => 'Version 1.1'))); $this->assertEquals(2, $s->create(array('project_id' => 1, 'name' => 'Version 1.2'))); $this->assertNotFalse($tc->create(array('project_id' => 1, 'title' => 'task1', 'swimlane_id' => 1))); $this->assertNotFalse($tc->create(array('project_id' => 1, 'title' => 'task2', 'swimlane_id' => 2))); $this->assertNotFalse($tc->create(array('project_id' => 1, 'title' => 'task3', 'swimlane_id' => 0))); $tf->search('swimlane:"Version 1.1"'); $tasks = $tf->findAll(); $this->assertNotEmpty($tasks); $this->assertCount(1, $tasks); $this->assertEquals('task1', $tasks[0]['title']); $this->assertEquals('Version 1.1', $tasks[0]['swimlane_name']); $tf->search('swimlane:"versioN 1.2"'); $tasks = $tf->findAll(); $this->assertNotEmpty($tasks); $this->assertCount(1, $tasks); $this->assertEquals('task2', $tasks[0]['title']); $this->assertEquals('Version 1.2', $tasks[0]['swimlane_name']); $tf->search('swimlane:"Default swimlane"'); $tasks = $tf->findAll(); $this->assertNotEmpty($tasks); $this->assertCount(1, $tasks); $this->assertEquals('task3', $tasks[0]['title']); $this->assertEquals('Default swimlane', $tasks[0]['default_swimlane']); $this->assertEquals('', $tasks[0]['swimlane_name']); $tf->search('swimlane:default'); $tasks = $tf->findAll(); $this->assertNotEmpty($tasks); $this->assertCount(1, $tasks); $this->assertEquals('task3', $tasks[0]['title']); $this->assertEquals('Default swimlane', $tasks[0]['default_swimlane']); $this->assertEquals('', $tasks[0]['swimlane_name']); $tf->search('swimlane:"Version 1.1" swimlane:"Version 1.2"'); $tasks = $tf->findAll(); $this->assertNotEmpty($tasks); $this->assertCount(2, $tasks); $this->assertEquals('task1', $tasks[0]['title']); $this->assertEquals('Version 1.1', $tasks[0]['swimlane_name']); $this->assertEquals('task2', $tasks[1]['title']); $this->assertEquals('Version 1.2', $tasks[1]['swimlane_name']); $tf->search('swimlane:"not found"'); $tasks = $tf->findAll(); $this->assertEmpty($tasks); }
public function testMoveDown() { $p = new Project($this->container); $s = new Swimlane($this->container); $this->assertEquals(1, $p->create(array('name' => 'UnitTest'))); $this->assertEquals(1, $s->create(1, 'Swimlane #1')); $this->assertEquals(2, $s->create(1, 'Swimlane #2')); $this->assertEquals(3, $s->create(1, 'Swimlane #3')); $swimlane = $s->getById(1); $this->assertNotEmpty($swimlane); $this->assertEquals(1, $swimlane['is_active']); $this->assertEquals(1, $swimlane['position']); $swimlane = $s->getById(2); $this->assertNotEmpty($swimlane); $this->assertEquals(1, $swimlane['is_active']); $this->assertEquals(2, $swimlane['position']); $swimlane = $s->getById(3); $this->assertNotEmpty($swimlane); $this->assertEquals(1, $swimlane['is_active']); $this->assertEquals(3, $swimlane['position']); // Move the swimlane 1 down $this->assertTrue($s->moveDown(1, 1)); $swimlane = $s->getById(1); $this->assertNotEmpty($swimlane); $this->assertEquals(1, $swimlane['is_active']); $this->assertEquals(2, $swimlane['position']); $swimlane = $s->getById(2); $this->assertNotEmpty($swimlane); $this->assertEquals(1, $swimlane['is_active']); $this->assertEquals(1, $swimlane['position']); $swimlane = $s->getById(3); $this->assertNotEmpty($swimlane); $this->assertEquals(1, $swimlane['is_active']); $this->assertEquals(3, $swimlane['position']); // Last swimlane can be moved down $this->assertFalse($s->moveDown(1, 3)); // Move with a disabled swimlane $this->assertTrue($s->disable(1, 3)); $swimlane = $s->getById(1); $this->assertNotEmpty($swimlane); $this->assertEquals(1, $swimlane['is_active']); $this->assertEquals(2, $swimlane['position']); $swimlane = $s->getById(2); $this->assertNotEmpty($swimlane); $this->assertEquals(1, $swimlane['is_active']); $this->assertEquals(1, $swimlane['position']); $swimlane = $s->getById(3); $this->assertNotEmpty($swimlane); $this->assertEquals(0, $swimlane['is_active']); $this->assertEquals(0, $swimlane['position']); // Move the 2st swimlane down $this->assertTrue($s->moveDown(1, 2)); $swimlane = $s->getById(1); $this->assertNotEmpty($swimlane); $this->assertEquals(1, $swimlane['is_active']); $this->assertEquals(1, $swimlane['position']); $swimlane = $s->getById(2); $this->assertNotEmpty($swimlane); $this->assertEquals(1, $swimlane['is_active']); $this->assertEquals(2, $swimlane['position']); $swimlane = $s->getById(3); $this->assertNotEmpty($swimlane); $this->assertEquals(0, $swimlane['is_active']); $this->assertEquals(0, $swimlane['position']); }
public function testEvents() { $tp = new TaskPosition($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(1, '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' => 2))); $this->container['dispatcher']->addListener(Task::EVENT_MOVE_COLUMN, array($this, 'onMoveColumn')); $this->container['dispatcher']->addListener(Task::EVENT_MOVE_POSITION, array($this, 'onMovePosition')); $this->container['dispatcher']->addListener(Task::EVENT_MOVE_SWIMLANE, array($this, 'onMoveSwimlane')); // We move the task 1 to the column 2 $this->assertTrue($tp->movePosition(1, 1, 2, 1)); $task = $tf->getById(1); $this->assertEquals(1, $task['id']); $this->assertEquals(2, $task['column_id']); $this->assertEquals(1, $task['position']); $task = $tf->getById(2); $this->assertEquals(2, $task['id']); $this->assertEquals(2, $task['column_id']); $this->assertEquals(2, $task['position']); $called = $this->container['dispatcher']->getCalledListeners(); $this->assertArrayHasKey(Task::EVENT_MOVE_COLUMN . '.TaskPositionTest::onMoveColumn', $called); $this->assertEquals(1, count($called)); // We move the task 1 to the position 2 $this->assertTrue($tp->movePosition(1, 1, 2, 2)); $task = $tf->getById(1); $this->assertEquals(1, $task['id']); $this->assertEquals(2, $task['column_id']); $this->assertEquals(2, $task['position']); $task = $tf->getById(2); $this->assertEquals(2, $task['id']); $this->assertEquals(2, $task['column_id']); $this->assertEquals(1, $task['position']); $called = $this->container['dispatcher']->getCalledListeners(); $this->assertArrayHasKey(Task::EVENT_MOVE_POSITION . '.TaskPositionTest::onMovePosition', $called); $this->assertEquals(2, count($called)); // Move to another swimlane $this->assertTrue($tp->movePosition(1, 1, 3, 1, 1)); $task = $tf->getById(1); $this->assertEquals(1, $task['id']); $this->assertEquals(3, $task['column_id']); $this->assertEquals(1, $task['position']); $this->assertEquals(1, $task['swimlane_id']); $task = $tf->getById(2); $this->assertEquals(2, $task['id']); $this->assertEquals(2, $task['column_id']); $this->assertEquals(1, $task['position']); $this->assertEquals(0, $task['swimlane_id']); $called = $this->container['dispatcher']->getCalledListeners(); $this->assertArrayHasKey(Task::EVENT_MOVE_SWIMLANE . '.TaskPositionTest::onMoveSwimlane', $called); $this->assertEquals(3, count($called)); }
public function testCloneProjectWithTasks() { $p = new Project($this->container); $pd = new ProjectDuplication($this->container); $s = new Swimlane($this->container); $tc = new TaskCreation($this->container); $tf = new TaskFinder($this->container); $this->assertEquals(1, $p->create(array('name' => 'P1'))); // create initial swimlanes $this->assertEquals(1, $s->create(array('project_id' => 1, 'name' => 'S1'))); $this->assertEquals(2, $s->create(array('project_id' => 1, 'name' => 'S2'))); $this->assertEquals(3, $s->create(array('project_id' => 1, 'name' => 'S3'))); $default_swimlane1 = $s->getDefault(1); $default_swimlane1['default_swimlane'] = 'New Default'; $this->assertTrue($s->updateDefault($default_swimlane1)); //create initial tasks $this->assertEquals(1, $tc->create(array('title' => 'T1', 'project_id' => 1, 'column_id' => 1, 'owner_id' => 1))); $this->assertEquals(2, $tc->create(array('title' => 'T2', 'project_id' => 1, 'column_id' => 2, 'owner_id' => 1))); $this->assertEquals(3, $tc->create(array('title' => 'T3', 'project_id' => 1, 'column_id' => 3, 'owner_id' => 1))); $this->assertNotFalse($pd->duplicate(1, array('category', 'action', 'task'))); $project = $p->getByName('P1 (Clone)'); $this->assertNotFalse($project); $project_id = $project['id']; // Check if Swimlanes have NOT been duplicated $this->assertCount(0, $s->getAll($project_id)); // Check if Tasks have been duplicated $tasks = $tf->getAll($project_id); $this->assertCount(3, $tasks); //$this->assertEquals(4, $tasks[0]['id']); $this->assertEquals('T1', $tasks[0]['title']); //$this->assertEquals(5, $tasks[1]['id']); $this->assertEquals('T2', $tasks[1]['title']); //$this->assertEquals(6, $tasks[2]['id']); $this->assertEquals('T3', $tasks[2]['title']); }