Add 3 new fields for tasks: start date, time estimated and time spent
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<php>
|
||||
<const name="API_URL" value="http://localhost:8080/jsonrpc.php" />
|
||||
<const name="API_URL" value="http://localhost:8000/jsonrpc.php" />
|
||||
<const name="API_KEY" value="19ffd9709d03ce50675c3a43d1c49c1ac207f4bc45f06c5b2701fbdf8929" />
|
||||
<const name="DB_DRIVER" value="mysql" />
|
||||
<const name="DB_NAME" value="kanboard" />
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<php>
|
||||
<const name="API_URL" value="http://localhost:8080/jsonrpc.php" />
|
||||
<const name="API_URL" value="http://localhost:8000/jsonrpc.php" />
|
||||
<const name="API_KEY" value="19ffd9709d03ce50675c3a43d1c49c1ac207f4bc45f06c5b2701fbdf8929" />
|
||||
<const name="DB_DRIVER" value="postgres" />
|
||||
<const name="DB_NAME" value="kanboard" />
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<php>
|
||||
<const name="API_URL" value="http://localhost:8080/jsonrpc.php" />
|
||||
<const name="API_URL" value="http://localhost:8000/jsonrpc.php" />
|
||||
<const name="API_KEY" value="19ffd9709d03ce50675c3a43d1c49c1ac207f4bc45f06c5b2701fbdf8929" />
|
||||
<const name="DB_DRIVER" value="sqlite" />
|
||||
<const name="DB_FILENAME" value="data/db.sqlite" />
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
<php>
|
||||
<const name="DB_DRIVER" value="postgres" />
|
||||
<const name="DB_USERNAME" value="postgres" />
|
||||
<const name="DB_PASSWORD" value="postgres" />
|
||||
<const name="DB_NAME" value="kanboard_unit_test" />
|
||||
</php>
|
||||
</phpunit>
|
||||
44
tests/units/TimeTrackingTest.php
Normal file
44
tests/units/TimeTrackingTest.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__.'/Base.php';
|
||||
|
||||
use Model\SubTask;
|
||||
use Model\Task;
|
||||
use Model\Project;
|
||||
use Model\TimeTracking;
|
||||
|
||||
class TimeTrackingTest extends Base
|
||||
{
|
||||
public function testCalculateTime()
|
||||
{
|
||||
$t = new Task($this->registry);
|
||||
$p = new Project($this->registry);
|
||||
$s = new SubTask($this->registry);
|
||||
$ts = new TimeTracking($this->registry);
|
||||
|
||||
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
|
||||
$this->assertEquals(1, $t->create(array('title' => 'Task #1', 'project_id' => 1, 'time_estimated' => 4.5)));
|
||||
$this->assertTrue($t->update(array('id' => 1, 'time_spent' => 3.5)));
|
||||
|
||||
$task = $t->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']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user