Esempio n. 1
0
 public function testCleanup()
 {
     $e = new TaskHistory($this->registry);
     $t = new Task($this->registry);
     $p = new Project($this->registry);
     $this->assertEquals(1, $p->create(array('name' => 'Project #1')));
     $this->assertEquals(1, $t->create(array('title' => 'Task #1', 'project_id' => 1)));
     $max = 15;
     $nb_events = 100;
     for ($i = 0; $i < $nb_events; $i++) {
         $this->assertTrue($e->create(1, 1, 1, Task::EVENT_CLOSE));
     }
     $this->assertEquals($nb_events, $this->registry->db->table('task_has_events')->count());
     $e->cleanup($max);
     $events = $e->getAllByProjectId(1);
     $this->assertNotEmpty($events);
     $this->assertTrue(is_array($events));
     $this->assertEquals($max, count($events));
     $this->assertEquals(100, $events[0]['id']);
     $this->assertEquals(99, $events[1]['id']);
     $this->assertEquals(86, $events[14]['id']);
     // Cleanup during task creation
     $nb_events = TaskHistory::MAX_EVENTS + 10;
     for ($i = 0; $i < $nb_events; $i++) {
         $this->assertTrue($e->create(1, 1, 1, Task::EVENT_CLOSE));
     }
     $this->assertEquals(TaskHistory::MAX_EVENTS, $this->registry->db->table('task_has_events')->count());
 }
Esempio n. 2
0
 public function testDuplicate()
 {
     $t = new Task($this->registry);
     $s = new SubTask($this->registry);
     $p = new Project($this->registry);
     // We create a project
     $this->assertEquals(1, $p->create(array('name' => 'test1')));
     // We create 2 tasks
     $this->assertEquals(1, $t->create(array('title' => 'test 1', 'project_id' => 1, 'column_id' => 1, 'owner_id' => 1)));
     $this->assertEquals(2, $t->create(array('title' => 'test 2', 'project_id' => 1, 'column_id' => 1, 'owner_id' => 0)));
     // We create many subtasks for the first task
     $this->assertEquals(1, $s->create(array('title' => 'subtask #1', 'task_id' => 1, 'time_estimated' => 5, 'time_spent' => 3, 'status' => 1)));
     $this->assertEquals(2, $s->create(array('title' => 'subtask #2', 'task_id' => 1, 'time_estimated' => 0, 'time_spent' => 0, 'status' => 2, 'user_id' => 1)));
     // We duplicate our subtasks
     $this->assertTrue($s->duplicate(1, 2));
     $subtasks = $s->getAll(2);
     $this->assertNotFalse($subtasks);
     $this->assertNotEmpty($subtasks);
     $this->assertEquals(2, count($subtasks));
     $this->assertEquals('subtask #1', $subtasks[0]['title']);
     $this->assertEquals('subtask #2', $subtasks[1]['title']);
     $this->assertEquals(2, $subtasks[0]['task_id']);
     $this->assertEquals(2, $subtasks[1]['task_id']);
     $this->assertEquals(5, $subtasks[0]['time_estimated']);
     $this->assertEquals(0, $subtasks[1]['time_estimated']);
     $this->assertEquals(0, $subtasks[0]['time_spent']);
     $this->assertEquals(0, $subtasks[1]['time_spent']);
     $this->assertEquals(0, $subtasks[0]['status']);
     $this->assertEquals(0, $subtasks[1]['status']);
     $this->assertEquals(0, $subtasks[0]['user_id']);
     $this->assertEquals(0, $subtasks[1]['user_id']);
 }
 public function testExecute()
 {
     $action = new Action\TaskAssignColorUser(1, new Task($this->registry));
     $action->setParam('user_id', 1);
     $action->setParam('color_id', 'blue');
     // We create a task in the first column
     $t = new Task($this->registry);
     $p = new Project($this->registry);
     $this->assertEquals(1, $p->create(array('name' => 'test')));
     $this->assertEquals(1, $t->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1, 'color_id' => 'green')));
     // We create an event to move the task to the 2nd column with a user id 5
     $event = array('project_id' => 1, 'task_id' => 1, 'column_id' => 2, 'owner_id' => 5);
     // Our event should NOT be executed
     $this->assertFalse($action->execute($event));
     // Our task should be assigned to nobody and have the green color
     $task = $t->getById(1);
     $this->assertNotEmpty($task);
     $this->assertEquals(0, $task['owner_id']);
     $this->assertEquals('green', $task['color_id']);
     // We create an event to move the task to the 2nd column with a user id 1
     $event = array('project_id' => 1, 'task_id' => 1, 'column_id' => 2, 'owner_id' => 1);
     // Our event should be executed
     $this->assertTrue($action->execute($event));
     // Our task should be assigned to nobody and have the blue color
     $task = $t->getById(1);
     $this->assertNotEmpty($task);
     $this->assertEquals(0, $task['owner_id']);
     $this->assertEquals('blue', $task['color_id']);
 }
 public function testExecute()
 {
     $action = new Action\TaskAssignColorCategory(1, new Task($this->registry));
     $action->setParam('category_id', 1);
     $action->setParam('color_id', 'blue');
     // We create a task in the first column
     $t = new Task($this->registry);
     $p = new Project($this->registry);
     $c = new Category($this->registry);
     $this->assertEquals(1, $p->create(array('name' => 'test')));
     $this->assertEquals(1, $c->create(array('name' => 'c1')));
     $this->assertEquals(2, $c->create(array('name' => 'c2')));
     $this->assertEquals(1, $t->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1, 'color_id' => 'green', 'category_id' => 2)));
     // We create an event but we don't do anything
     $event = array('project_id' => 1, 'task_id' => 1, 'column_id' => 1, 'category_id' => 2, 'position' => 2);
     // Our event should NOT be executed
     $this->assertFalse($action->execute($event));
     // Our task should be assigned to the ategory_id=1 and have the green color
     $task = $t->getById(1);
     $this->assertNotEmpty($task);
     $this->assertEquals(2, $task['category_id']);
     $this->assertEquals('green', $task['color_id']);
     // We create an event to move the task
     $event = array('project_id' => 1, 'task_id' => 1, 'column_id' => 1, 'position' => 5, 'category_id' => 1);
     // Our event should be executed
     $this->assertTrue($action->execute($event));
     // Our task should have the blue color
     $task = $t->getById(1);
     $this->assertNotEmpty($task);
     $this->assertEquals('blue', $task['color_id']);
 }
 public function testExecute()
 {
     $action = new Action\TaskMoveAnotherProject(1, new Task($this->registry));
     // We create a task in the first column
     $t = new Task($this->registry);
     $p = new Project($this->registry);
     $this->assertEquals(1, $p->create(array('name' => 'project 1')));
     $this->assertEquals(2, $p->create(array('name' => 'project 2')));
     $this->assertEquals(1, $t->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1)));
     // We create an event to move the task to the 2nd column
     $event = array('project_id' => 1, 'task_id' => 1, 'column_id' => 2);
     // Our event should NOT be executed because we define the same project
     $action->setParam('column_id', 2);
     $action->setParam('project_id', 1);
     $this->assertFalse($action->execute($event));
     // Our task should be assigned to the project 1
     $task = $t->getById(1);
     $this->assertNotEmpty($task);
     $this->assertEquals(1, $task['project_id']);
     // We create an event to move the task to the 2nd column
     $event = array('project_id' => 1, 'task_id' => 1, 'column_id' => 2);
     // Our event should be executed because we define a different project
     $action->setParam('column_id', 2);
     $action->setParam('project_id', 2);
     $this->assertTrue($action->execute($event));
     // Our task should be assigned to the project 2
     $task = $t->getById(1);
     $this->assertNotEmpty($task);
     $this->assertEquals(2, $task['project_id']);
 }
 /**
  * Execute the action
  *
  * @access public
  * @param  array   $data   Event data dictionary
  * @return bool            True if the action was executed or false when not executed
  */
 public function doAction(array $data)
 {
     if ($data['column_id'] == $this->getParam('column_id')) {
         $this->task->update(array('id' => $data['task_id'], 'owner_id' => $this->acl->getUserId()));
         return true;
     }
     return false;
 }
 /**
  * Execute the action
  *
  * @access public
  * @param  array   $data   Event data dictionary
  * @return bool            True if the action was executed or false when not executed
  */
 public function doAction(array $data)
 {
     if ($data['column_id'] == $this->getParam('column_id') && $data['project_id'] != $this->getParam('project_id')) {
         $this->task->duplicateToAnotherProject($data['task_id'], $this->getParam('project_id'));
         return true;
     }
     return false;
 }
Esempio n. 8
0
 /**
  * Execute the action
  *
  * @access public
  * @param  array   $data   Event data dictionary
  * @return bool            True if the action was executed or false when not executed
  */
 public function doAction(array $data)
 {
     if ($data['column_id'] == $this->getParam('column_id')) {
         $this->task->close($data['task_id']);
         return true;
     }
     return false;
 }
Esempio n. 9
0
 /**
  * Execute the action
  *
  * @access public
  * @param  array   $data   Event data dictionary
  * @return bool            True if the action was executed or false when not executed
  */
 public function doAction(array $data)
 {
     if ($data['owner_id'] == $this->getParam('user_id')) {
         $this->task->update(array('id' => $data['task_id'], 'color_id' => $this->getParam('color_id')), false);
         return true;
     }
     return false;
 }
Esempio n. 10
0
 /**
  * Execute the action
  *
  * @access public
  * @param  array   $data   Event data dictionary
  * @return bool            True if the action was executed or false when not executed
  */
 public function doAction(array $data)
 {
     if ($data['column_id'] == $this->getParam('column_id') && $data['project_id'] != $this->getParam('project_id')) {
         $task = $this->task->getById($data['task_id']);
         $this->task->moveToAnotherProject($this->getParam('project_id'), $task);
         return true;
     }
     return false;
 }
Esempio n. 11
0
 public function testRemove()
 {
     $t = new Task($this->container);
     $tc = new TaskCreation($this->container);
     $tf = new TaskFinder($this->container);
     $p = new Project($this->container);
     $this->assertEquals(1, $p->create(array('name' => 'UnitTest')));
     $this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1)));
     $this->assertTrue($t->remove(1));
     $this->assertFalse($t->remove(1234));
 }
Esempio n. 12
0
 public function validateRemove()
 {
     $c = new Comment($this->registry);
     $t = new Task($this->registry);
     $p = new Project($this->registry);
     $this->assertEquals(1, $p->create(array('name' => 'test1')));
     $this->assertEquals(1, $t->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 3, 'owner_id' => 1)));
     $this->assertTrue($c->create(array('task_id' => 1, 'comment' => 'c1', 'user_id' => 1)));
     $this->assertTrue($c->remove(1));
     $this->assertFalse($c->remove(1));
     $this->assertFalse($c->remove(1111));
 }
Esempio n. 13
0
 public function testUpdate()
 {
     $c = new Comment($this->registry);
     $t = new Task($this->registry);
     $p = new Project($this->registry);
     $this->assertEquals(1, $p->create(array('name' => 'test1')));
     $this->assertEquals(1, $t->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 3, 'owner_id' => 1)));
     $this->assertTrue($c->create(array('task_id' => 1, 'comment' => 'c1', 'user_id' => 1)));
     $this->assertTrue($c->update(array('id' => 1, 'comment' => 'bla')));
     $comment = $c->getById(1);
     $this->assertNotEmpty($comment);
     $this->assertEquals('bla', $comment['comment']);
 }
Esempio n. 14
0
 public function testIsLastModified()
 {
     $p = new Project($this->registry);
     $t = new Task($this->registry);
     $now = time();
     $p->attachEvents();
     $this->assertEquals(1, $p->create(array('name' => 'UnitTest')));
     $project = $p->getById(1);
     $this->assertNotEmpty($project);
     $this->assertEquals($now, $project['last_modified']);
     sleep(1);
     $this->assertEquals(1, $t->create(array('title' => 'Task #1', 'project_id' => 1)));
     $this->assertTrue($this->registry->shared('event')->isEventTriggered(Task::EVENT_CREATE));
     $this->assertEquals('Event\\ProjectModificationDate', $this->registry->shared('event')->getLastListenerExecuted());
     $project = $p->getById(1);
     $this->assertNotEmpty($project);
     $this->assertTrue($p->isModifiedSince(1, $now));
 }
Esempio n. 15
0
 public function testExecute()
 {
     $action = new Action\TaskClose(1, new Task($this->registry));
     $action->setParam('column_id', 2);
     // We create a task in the first column
     $t = new Task($this->registry);
     $p = new Project($this->registry);
     $this->assertEquals(1, $p->create(array('name' => 'test')));
     $this->assertEquals(1, $t->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1)));
     // We create an event to move the task to the 2nd column
     $event = array('project_id' => 1, 'task_id' => 1, 'column_id' => 2);
     // Our event should be executed
     $this->assertTrue($action->execute($event));
     // Our task should be closed
     $task = $t->getById(1);
     $this->assertNotEmpty($task);
     $this->assertEquals(0, $task['is_active']);
 }
Esempio n. 16
0
 public function testRemove()
 {
     $t = new Task($this->registry);
     $p = new Project($this->registry);
     $c = new Category($this->registry);
     $this->assertEquals(1, $p->create(array('name' => 'Project #1')));
     $this->assertEquals(1, $c->create(array('name' => 'Category #1', 'project_id' => 1)));
     $this->assertEquals(2, $c->create(array('name' => 'Category #2', 'project_id' => 1)));
     $this->assertEquals(1, $t->create(array('title' => 'Task #1', 'project_id' => 1, 'category_id' => 2)));
     $task = $t->getById(1);
     $this->assertTrue(is_array($task));
     $this->assertEquals(2, $task['category_id']);
     $this->assertTrue($c->remove(1));
     $this->assertTrue($c->remove(2));
     // Make sure tasks assigned with that category are reseted
     $task = $t->getById(1);
     $this->assertTrue(is_array($task));
     $this->assertEquals(0, $task['category_id']);
 }
Esempio n. 17
0
 public function testRemove()
 {
     $u = new User($this->registry);
     $t = new Task($this->registry);
     $p = new Project($this->registry);
     $this->assertTrue($u->create(array('username' => 'toto', 'password' => '123456', 'name' => 'Toto')));
     $this->assertEquals(1, $p->create(array('name' => 'Project #1')));
     $this->assertEquals(1, $t->create(array('title' => 'Task #1', 'project_id' => 1, 'owner_id' => 2)));
     $task = $t->getById(1);
     $this->assertEquals(1, $task['id']);
     $this->assertEquals(2, $task['owner_id']);
     $this->assertTrue($u->remove(1));
     $this->assertTrue($u->remove(2));
     $this->assertFalse($u->remove(2));
     $this->assertFalse($u->remove(55));
     // Make sure that assigned tasks are unassigned after removing the user
     $task = $t->getById(1);
     $this->assertEquals(1, $task['id']);
     $this->assertEquals(0, $task['owner_id']);
 }
 public function testExecute()
 {
     $action = new Action\TaskAssignCurrentUser(1, new Task($this->registry), new Acl($this->registry));
     $action->setParam('column_id', 2);
     $_SESSION = array('user' => array('id' => 5));
     // We create a task in the first column
     $t = new Task($this->registry);
     $p = new Project($this->registry);
     $a = new Acl($this->registry);
     $this->assertEquals(5, $a->getUserId());
     $this->assertEquals(1, $p->create(array('name' => 'test')));
     $this->assertEquals(1, $t->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1)));
     // We create an event to move the task to the 2nd column
     $event = array('project_id' => 1, 'task_id' => 1, 'column_id' => 2);
     // Our event should be executed
     $this->assertTrue($action->execute($event));
     // Our task should be assigned to the user 5 (from the session)
     $task = $t->getById(1);
     $this->assertNotEmpty($task);
     $this->assertEquals(1, $task['id']);
     $this->assertEquals(5, $task['owner_id']);
 }
Esempio n. 19
0
 public function testRecurrenceSettings()
 {
     $t = new Task($this->container);
     $statuses = $t->getRecurrenceStatusList();
     $this->assertCount(2, $statuses);
     $this->assertArrayHasKey(Task::RECURRING_STATUS_NONE, $statuses);
     $this->assertArrayHasKey(Task::RECURRING_STATUS_PENDING, $statuses);
     $this->assertArrayNotHasKey(Task::RECURRING_STATUS_PROCESSED, $statuses);
     $triggers = $t->getRecurrenceTriggerList();
     $this->assertCount(3, $triggers);
     $this->assertArrayHasKey(Task::RECURRING_TRIGGER_FIRST_COLUMN, $triggers);
     $this->assertArrayHasKey(Task::RECURRING_TRIGGER_LAST_COLUMN, $triggers);
     $this->assertArrayHasKey(Task::RECURRING_TRIGGER_CLOSE, $triggers);
     $dates = $t->getRecurrenceBasedateList();
     $this->assertCount(2, $dates);
     $this->assertArrayHasKey(Task::RECURRING_BASEDATE_DUEDATE, $dates);
     $this->assertArrayHasKey(Task::RECURRING_BASEDATE_TRIGGERDATE, $dates);
     $timeframes = $t->getRecurrenceTimeframeList();
     $this->assertCount(3, $timeframes);
     $this->assertArrayHasKey(Task::RECURRING_TIMEFRAME_DAYS, $timeframes);
     $this->assertArrayHasKey(Task::RECURRING_TIMEFRAME_MONTHS, $timeframes);
     $this->assertArrayHasKey(Task::RECURRING_TIMEFRAME_YEARS, $timeframes);
 }
Esempio n. 20
0
 /**
  * Display the template show task (common between different actions)
  *
  * @access protected
  * @param  array  $task               Task data
  * @param  array  $comment_form       Comment form data
  * @param  array  $description_form   Description form data
  * @param  array  $comment_edit_form  Comment edit form data
  */
 protected function showTask(array $task, array $comment_form = array(), array $description_form = array(), array $comment_edit_form = array())
 {
     if (empty($comment_form)) {
         $comment_form = array('values' => array('task_id' => $task['id'], 'user_id' => $this->acl->getUserId()), 'errors' => array());
     }
     if (empty($description_form)) {
         $description_form = array('values' => array('id' => $task['id']), 'errors' => array());
     }
     if (empty($comment_edit_form)) {
         $comment_edit_form = array('values' => array('id' => 0), 'errors' => array());
     } else {
         $hide_comment_form = true;
     }
     $this->response->html($this->template->layout('task_show', array('hide_comment_form' => isset($hide_comment_form), 'comment_edit_form' => $comment_edit_form, 'comment_form' => $comment_form, 'description_form' => $description_form, 'comments' => $this->comment->getAll($task['id']), 'task' => $task, 'columns_list' => $this->board->getColumnsList($task['project_id']), 'colors_list' => $this->task->getColors(), 'menu' => 'tasks', 'title' => $task['title'])));
 }
Esempio n. 21
0
 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)));
 }
Esempio n. 22
0
 public function testEventMovePosition()
 {
     $task = new Task($this->registry);
     $board = new Board($this->registry);
     $project = new Project($this->registry);
     $action = new Action($this->registry);
     // We create a project
     $this->assertEquals(1, $project->create(array('name' => 'unit_test')));
     // We create a task
     $this->assertEquals(1, $task->create(array('title' => 'unit_test 0', 'project_id' => 1, 'owner_id' => 1, 'color_id' => 'red', 'column_id' => 1, 'category_id' => 1)));
     $this->assertEquals(2, $task->create(array('title' => 'unit_test 1', 'project_id' => 1, 'owner_id' => 1, 'color_id' => 'yellow', 'column_id' => 1, 'category_id' => 1)));
     // We create a new action, when the category_id=2 then the color_id should be green
     $this->assertTrue($action->create(array('project_id' => 1, 'event_name' => Task::EVENT_MOVE_POSITION, 'action_name' => 'TaskAssignColorCategory', 'params' => array('category_id' => 1, 'color_id' => 'green'))));
     // We bind events
     $action->attachEvents();
     $this->assertTrue($this->registry->event->hasListener(Task::EVENT_MOVE_POSITION, 'Action\\TaskAssignColorCategory'));
     // Our task should have the color red and position=1
     $t1 = $task->getById(1);
     $this->assertEquals(1, $t1['position']);
     $this->assertEquals(1, $t1['is_active']);
     $this->assertEquals('red', $t1['color_id']);
     $t1 = $task->getById(2);
     $this->assertEquals(2, $t1['position']);
     $this->assertEquals(1, $t1['is_active']);
     $this->assertEquals('yellow', $t1['color_id']);
     // We move our tasks
     $this->assertTrue($task->movePosition(1, 1, 1, 10));
     // task #1 to the end of the column
     $this->assertTrue($this->registry->event->isEventTriggered(Task::EVENT_MOVE_POSITION));
     $t1 = $task->getById(1);
     $this->assertEquals(2, $t1['position']);
     $this->assertEquals(1, $t1['is_active']);
     $this->assertEquals('green', $t1['color_id']);
     $t1 = $task->getById(2);
     $this->assertEquals(1, $t1['position']);
     $this->assertEquals(1, $t1['is_active']);
     $this->assertEquals('yellow', $t1['color_id']);
     $this->registry->event->clearTriggeredEvents();
     $this->assertTrue($task->movePosition(1, 2, 1, 44));
     // task #2 to position 1
     $this->assertTrue($this->registry->event->isEventTriggered(Task::EVENT_MOVE_POSITION));
     $this->assertEquals('Action\\TaskAssignColorCategory', $this->registry->event->getLastListenerExecuted());
     $t1 = $task->getById(1);
     $this->assertEquals(1, $t1['position']);
     $this->assertEquals(1, $t1['is_active']);
     $this->assertEquals('green', $t1['color_id']);
     $t1 = $task->getById(2);
     $this->assertEquals(2, $t1['position']);
     $this->assertEquals(1, $t1['is_active']);
     $this->assertEquals('green', $t1['color_id']);
 }
Esempio n. 23
0
 public function testExecuteMultipleActions()
 {
     $task = new Task($this->registry);
     $board = new Board($this->registry);
     $project = new Project($this->registry);
     $action = new Action($this->registry);
     // We create 2 projects
     $this->assertEquals(1, $project->create(array('name' => 'unit_test1')));
     $this->assertEquals(2, $project->create(array('name' => 'unit_test2')));
     // We create a task
     $this->assertEquals(1, $task->create(array('title' => 'unit_test', 'project_id' => 1, 'owner_id' => 1, 'color_id' => 'red', 'column_id' => 1)));
     // We create 2 actions
     $this->assertTrue($action->create(array('project_id' => 1, 'event_name' => Task::EVENT_CLOSE, 'action_name' => 'TaskDuplicateAnotherProject', 'params' => array('column_id' => 4, 'project_id' => 2))));
     $this->assertTrue($action->create(array('project_id' => 1, 'event_name' => Task::EVENT_MOVE_COLUMN, 'action_name' => 'TaskClose', 'params' => array('column_id' => 4))));
     // We bind events
     $action->attachEvents();
     // Events should be attached
     $this->assertTrue($this->registry->shared('event')->hasListener(Task::EVENT_CLOSE, 'Action\\TaskDuplicateAnotherProject'));
     $this->assertTrue($this->registry->shared('event')->hasListener(Task::EVENT_MOVE_COLUMN, 'Action\\TaskClose'));
     // Our task should be open, linked to the first project and in the first column
     $t1 = $task->getById(1);
     $this->assertEquals(1, $t1['is_active']);
     $this->assertEquals(1, $t1['column_id']);
     $this->assertEquals(1, $t1['project_id']);
     // We move our task
     $task->movePosition(1, 1, 4, 1);
     $this->assertTrue($this->registry->shared('event')->isEventTriggered(Task::EVENT_CLOSE));
     $this->assertTrue($this->registry->shared('event')->isEventTriggered(Task::EVENT_MOVE_COLUMN));
     // Our task should be closed
     $t1 = $task->getById(1);
     $this->assertEquals(4, $t1['column_id']);
     $this->assertEquals(0, $t1['is_active']);
     // Our task should be duplicated to the 2nd project
     $t2 = $task->getById(2);
     $this->assertNotEmpty($t2);
     $this->assertNotEquals(4, $t2['column_id']);
     $this->assertEquals(1, $t2['is_active']);
     $this->assertEquals(2, $t2['project_id']);
     $this->assertEquals('unit_test', $t2['title']);
 }
Esempio n. 24
0
#!/usr/bin/env php
<?php 
require __DIR__ . '/../app/common.php';
use Model\Task;
$task_per_column = 250;
$taskModel = new Task($registry);
foreach (array(1, 2, 3, 4) as $column_id) {
    for ($i = 1; $i <= $task_per_column; $i++) {
        $task = array('title' => 'Task #' . $i . '-' . $column_id, 'project_id' => 1, 'column_id' => $column_id, 'owner_id' => rand(0, 1), 'color_id' => rand(0, 1) === 0 ? 'green' : 'purple', 'score' => rand(0, 21));
        $taskModel->create($task);
    }
}
Esempio n. 25
0
 /**
  * Get all columns and tasks for a given project
  *
  * @access public
  * @param  integer  $project_id   Project id
  * @return array
  */
 public function get($project_id, array $filters = array())
 {
     $this->db->startTransaction();
     $columns = $this->getColumns($project_id);
     $filters[] = array('column' => 'project_id', 'operator' => 'eq', 'value' => $project_id);
     $filters[] = array('column' => 'is_active', 'operator' => 'eq', 'value' => Task::STATUS_OPEN);
     $taskModel = new Task($this->db, $this->event);
     $tasks = $taskModel->find($filters);
     foreach ($columns as &$column) {
         $column['tasks'] = array();
         foreach ($tasks as &$task) {
             if ($task['column_id'] == $column['id']) {
                 $column['tasks'][] = $task;
             }
         }
     }
     $this->db->closeTransaction();
     return $columns;
 }
Esempio n. 26
0
    $task->done($id);
    return $app->redirect($app['url_generator']->generate('account'));
})->bind('done');
$app->get('/task/delete/{id}', function ($id) use($app) {
    if (null === $app['session']->get('session_login')) {
        return $app['twig']->render('auth/form.twig', ['errorMessage' => 'You should authenticate first']);
    }
    $task = new Task($app['pdo']);
    $task->delete($id);
    return $app->redirect($app['url_generator']->generate('account'));
})->bind('delete');
$app->get('/task/remove/{id}', function ($id) use($app) {
    if (null === $app['session']->get('session_login')) {
        return $app['twig']->render('auth/form.twig', ['errorMessage' => 'You should authenticate first']);
    }
    $task = new Task($app['pdo']);
    $task->remove($id);
    return $app->redirect($app['url_generator']->generate('account'));
});
$app->post('/auth', function () use($app) {
    $login = $app['request']->get('login');
    $pass = $app['request']->get('pass');
    $auth = new \Model\Auth($app['pdo']);
    if ($auth->isUserFound($login, $pass)) {
        $app['session']->set('session_login', $login);
        return $app->redirect($app['url_generator']->generate('account'));
    } else {
        return $app['twig']->render('auth/form.twig', ['errorMessage' => 'Wrong login or password!']);
    }
});
// party should go on :)
Esempio n. 27
0
 /**
  * Get all projects, optionaly fetch stats for each project and can check users permissions
  *
  * @access public
  * @param  bool       $fetch_stats          If true, return metrics about each projects
  * @param  bool       $check_permissions    If true, remove projects not allowed for the current user
  * @return array
  */
 public function getAll($fetch_stats = false, $check_permissions = false)
 {
     if (!$fetch_stats) {
         return $this->db->table(self::TABLE)->asc('name')->findAll();
     }
     $this->db->startTransaction();
     $projects = $this->db->table(self::TABLE)->asc('name')->findAll();
     $boardModel = new Board($this->db, $this->event);
     $taskModel = new Task($this->db, $this->event);
     $aclModel = new Acl($this->db, $this->event);
     foreach ($projects as $pkey => &$project) {
         if ($check_permissions && !$this->isUserAllowed($project['id'], $aclModel->getUserId())) {
             unset($projects[$pkey]);
         } else {
             $columns = $boardModel->getcolumns($project['id']);
             $project['nb_active_tasks'] = 0;
             foreach ($columns as &$column) {
                 $column['nb_active_tasks'] = $taskModel->countByColumnId($project['id'], $column['id']);
                 $project['nb_active_tasks'] += $column['nb_active_tasks'];
             }
             $project['columns'] = $columns;
             $project['nb_tasks'] = $taskModel->countByProjectId($project['id']);
             $project['nb_inactive_tasks'] = $project['nb_tasks'] - $project['nb_active_tasks'];
         }
     }
     $this->db->closeTransaction();
     return $projects;
 }
Esempio n. 28
0
#!/usr/bin/env php
<?php 
require __DIR__ . '/../app/common.php';
use Model\ProjectDailySummary;
use Model\Task;
$pds = new ProjectDailySummary($container);
$taskModel = new Task($container);
for ($i = 1; $i <= 15; $i++) {
    $task = array('title' => 'Task #' . $i, 'project_id' => 1, 'column_id' => 1);
    $taskModel->create($task);
}
$pds->updateTotals(1, date('Y-m-d', strtotime('-7 days')));
$taskModel->movePosition(1, 1, 2, 1);
$taskModel->movePosition(1, 2, 2, 1);
$taskModel->movePosition(1, 3, 2, 1);
$pds->updateTotals(1, date('Y-m-d', strtotime('-6 days')));
$taskModel->movePosition(1, 3, 3, 1);
$taskModel->movePosition(1, 4, 3, 1);
$taskModel->movePosition(1, 5, 3, 1);
$pds->updateTotals(1, date('Y-m-d', strtotime('-5 days')));
$taskModel->movePosition(1, 5, 4, 1);
$taskModel->movePosition(1, 6, 4, 1);
$pds->updateTotals(1, date('Y-m-d', strtotime('-4 days')));
$taskModel->movePosition(1, 7, 4, 1);
$taskModel->movePosition(1, 8, 4, 1);
$pds->updateTotals(1, date('Y-m-d', strtotime('-3 days')));
$taskModel->movePosition(1, 9, 3, 1);
$taskModel->movePosition(1, 10, 2, 1);
$pds->updateTotals(1, date('Y-m-d', strtotime('-2 days')));
$taskModel->create(array('title' => 'Random task', 'project_id' => 1));
$taskModel->movePosition(1, 11, 2, 1);
Esempio n. 29
0
 public function testEvents()
 {
     $t = new Task($this->registry);
     $p = new Project($this->registry);
     // We create a project
     $this->assertEquals(1, $p->create(array('name' => 'test')));
     // We create task
     $this->assertEquals(1, $t->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1)));
     $this->assertTrue($this->registry->event->isEventTriggered(Task::EVENT_CREATE));
     // We update a task
     $this->assertTrue($t->update(array('title' => 'test2', 'id' => 1)));
     $this->assertTrue($this->registry->event->isEventTriggered(Task::EVENT_UPDATE));
     $this->assertTrue($this->registry->event->isEventTriggered(Task::EVENT_CREATE_UPDATE));
     // We close our task
     $this->assertTrue($t->close(1));
     $this->assertTrue($this->registry->event->isEventTriggered(Task::EVENT_CLOSE));
     // We open our task
     $this->assertTrue($t->open(1));
     $this->assertTrue($this->registry->event->isEventTriggered(Task::EVENT_OPEN));
     // We change the column of our task
     $this->assertTrue($t->movePosition(1, 1, 2, 1));
     $this->assertTrue($this->registry->event->isEventTriggered(Task::EVENT_MOVE_COLUMN));
     // We change the position of our task
     $this->assertEquals(2, $t->create(array('title' => 'test 2', 'project_id' => 1, 'column_id' => 2)));
     $this->assertTrue($t->movePosition(1, 1, 2, 2));
     $this->assertTrue($this->registry->event->isEventTriggered(Task::EVENT_MOVE_POSITION));
     // We change the column and the position of our task
     $this->assertTrue($t->movePosition(1, 1, 1, 1));
     $this->assertTrue($this->registry->event->isEventTriggered(Task::EVENT_MOVE_COLUMN));
 }
Esempio n. 30
0
use Core\Translator;
use JsonRPC\Server;
use Model\Project;
use Model\Task;
use Model\User;
use Model\Config;
use Model\Category;
use Model\Comment;
use Model\SubTask;
use Model\Board;
use Model\Action;
use Model\Webhook;
use Model\Notification;
$config = new Config($registry);
$project = new Project($registry);
$task = new Task($registry);
$user = new User($registry);
$category = new Category($registry);
$comment = new Comment($registry);
$subtask = new SubTask($registry);
$board = new Board($registry);
$action = new Action($registry);
$webhook = new Webhook($registry);
$notification = new Notification($registry);
$action->attachEvents();
$project->attachEvents();
$webhook->attachEvents();
$notification->attachEvents();
// Load translations
$language = $config->get('language', 'en_US');
if ($language !== 'en_US') {