示例#1
0
 public function testGetAll()
 {
     $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->create(array('task_id' => 1, 'comment' => 'c2', 'user_id' => 1)));
     $this->assertTrue($c->create(array('task_id' => 1, 'comment' => 'c3', 'user_id' => 1)));
     $comments = $c->getAll(1);
     $this->assertNotEmpty($comments);
     $this->assertEquals(3, count($comments));
     $this->assertEquals(1, $comments[0]['id']);
     $this->assertEquals(2, $comments[1]['id']);
     $this->assertEquals(3, $comments[2]['id']);
 }
示例#2
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'])));
 }
示例#3
0
});
$server->register('removeCategory', function ($category_id) use($category) {
    return $category->remove($category_id);
});
/**
 * Comments procedures
 */
$server->register('createComment', function (array $values) use($comment) {
    list($valid, ) = $comment->validateCreation($values);
    return $valid && $comment->create($values);
});
$server->register('getComment', function ($comment_id) use($comment) {
    return $comment->getById($comment_id);
});
$server->register('getAllComments', function ($task_id) use($comment) {
    return $comment->getAll($task_id);
});
$server->register('updateComment', function ($values) use($comment) {
    list($valid, ) = $comment->validateModification($values);
    return $valid && $comment->update($values);
});
$server->register('removeComment', function ($comment_id) use($comment) {
    return $comment->remove($comment_id);
});
/**
 * Subtask procedures
 */
$server->register('createSubtask', function (array $values) use($subtask) {
    list($valid, ) = $subtask->validate($values);
    return $valid && $subtask->create($values);
});