Пример #1
0
 public function testDuplicate()
 {
     $tc = new TaskCreation($this->container);
     $s = new SubTask($this->container);
     $p = new Project($this->container);
     // We create a project
     $this->assertEquals(1, $p->create(array('name' => 'test1')));
     // We create 2 tasks
     $this->assertEquals(1, $tc->create(array('title' => 'test 1', 'project_id' => 1, 'column_id' => 1, 'owner_id' => 1)));
     $this->assertEquals(2, $tc->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, 'another_subtask' => 'on')));
     $this->assertEquals(2, $s->create(array('title' => 'subtask #2', 'task_id' => 1, 'time_estimated' => '', 'time_spent' => '', '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']);
 }
Пример #2
0
 public function testCalculateTime()
 {
     $tm = new TaskModification($this->container);
     $tc = new TaskCreation($this->container);
     $tf = new TaskFinder($this->container);
     $p = new Project($this->container);
     $s = new SubTask($this->container);
     $ts = new TimeTracking($this->container);
     $this->assertEquals(1, $p->create(array('name' => 'Project #1')));
     $this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1, 'time_estimated' => 4.5)));
     $this->assertTrue($tm->update(array('id' => 1, 'time_spent' => 3.5)));
     $task = $tf->getById(1);
     $this->assertNotEmpty($task);
     $this->assertEquals(4.5, $task['time_estimated']);
     $this->assertEquals(3.5, $task['time_spent']);
     $timesheet = $ts->getTaskTimesheet($task, array());
     $this->assertNotEmpty($timesheet);
     $this->assertEquals(4.5, $timesheet['time_estimated']);
     $this->assertEquals(3.5, $timesheet['time_spent']);
     $this->assertEquals(1, $timesheet['time_remaining']);
     // Subtasks calculation
     $this->assertEquals(1, $s->create(array('title' => 'subtask #1', 'task_id' => 1, 'time_estimated' => 5.5, 'time_spent' => 3)));
     $this->assertEquals(2, $s->create(array('title' => 'subtask #2', 'task_id' => 1, 'time_estimated' => '', 'time_spent' => 4)));
     $timesheet = $ts->getTaskTimesheet($task, $s->getAll(1));
     $this->assertNotEmpty($timesheet);
     $this->assertEquals(5.5, $timesheet['time_estimated']);
     $this->assertEquals(7, $timesheet['time_spent']);
     $this->assertEquals(-1.5, $timesheet['time_remaining']);
 }
Пример #3
0
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') {
    Translator::load($language);
}
$server = new Server();
$server->authentication(array('jsonrpc' => $config->get('api_token')));
Пример #4
0
#!/usr/bin/env php
<?php 
require __DIR__ . '/../app/common.php';
use Model\TaskCreation;
use Model\SubTask;
use Model\Project;
use Model\ProjectPermission;
use Model\User;
$task_per_column = 200;
$userModel = new User($container);
$projectModel = new Project($container);
$permissionModel = new ProjectPermission($container);
$taskModel = new TaskCreation($container);
$subtaskModel = new SubTask($container);
$project_id = $projectModel->create(array('name' => 'Project #1'));
$permissionModel->addMember($project_id, 1);
for ($i = 0; $i <= 5; $i++) {
    $userModel->create(array('username' => 'user' . $i, 'password' => 'password' . $i, 'name' => 'User #' . $i, 'email' => 'user' . $i . '@localhost'));
}
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' => 1, 'color_id' => mt_rand(0, 1) === 0 ? 'green' : 'purple', 'score' => mt_rand(0, 21), 'is_active' => mt_rand(0, 1));
        $id = $taskModel->create($task);
        $subtaskModel->create(array('title' => 'Subtask of task #' . $id, 'user_id' => 1, 'status' => mt_rand(0, 2), 'task_id' => $id));
    }
}