summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog2
-rw-r--r--app/Api/Procedure/SubtaskTimeTrackingProcedure.php8
-rw-r--r--doc/api-json-rpc.markdown1
-rw-r--r--doc/api-subtask-time-tracking-procedures.markdown102
-rw-r--r--tests/integration/BaseProcedureTest.php11
-rw-r--r--tests/integration/SubtaskProcedureTest.php11
-rw-r--r--tests/integration/SubtaskTimeTrackingProcedureTest.php46
7 files changed, 165 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 7a56139c..eccff6a3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,7 +5,7 @@ New features:
* Added application and project roles validation for API procedure calls
* Added new API call: "getProjectByIdentifier"
-* Added new API calls for external task links, project attachments
+* Added new API calls for external task links, project attachments and subtask time tracking
Improvements:
diff --git a/app/Api/Procedure/SubtaskTimeTrackingProcedure.php b/app/Api/Procedure/SubtaskTimeTrackingProcedure.php
index b6d1102a..5ceaa08d 100644
--- a/app/Api/Procedure/SubtaskTimeTrackingProcedure.php
+++ b/app/Api/Procedure/SubtaskTimeTrackingProcedure.php
@@ -19,15 +19,15 @@ class SubtaskTimeTrackingProcedure extends BaseProcedure
return $this->subtaskTimeTrackingModel->hasTimer($subtask_id, $user_id);
}
- public function logSubtaskStartTime($subtask_id, $user_id)
+ public function setSubtaskStartTime($subtask_id, $user_id)
{
- SubtaskAuthorization::getInstance($this->container)->check($this->getClassName(), 'logSubtaskStartTime', $subtask_id);
+ SubtaskAuthorization::getInstance($this->container)->check($this->getClassName(), 'setSubtaskStartTime', $subtask_id);
return $this->subtaskTimeTrackingModel->logStartTime($subtask_id, $user_id);
}
- public function logSubtaskEndTime($subtask_id, $user_id)
+ public function setSubtaskEndTime($subtask_id, $user_id)
{
- SubtaskAuthorization::getInstance($this->container)->check($this->getClassName(), 'logSubtaskEndTime', $subtask_id);
+ SubtaskAuthorization::getInstance($this->container)->check($this->getClassName(), 'setSubtaskEndTime', $subtask_id);
return $this->subtaskTimeTrackingModel->logEndTime($subtask_id, $user_id);
}
diff --git a/doc/api-json-rpc.markdown b/doc/api-json-rpc.markdown
index 6498b0cc..ab1056f0 100644
--- a/doc/api-json-rpc.markdown
+++ b/doc/api-json-rpc.markdown
@@ -58,6 +58,7 @@ Usage
- [Automatic Actions](api-action-procedures.markdown)
- [Tasks](api-task-procedures.markdown)
- [Subtasks](api-subtask-procedures.markdown)
+- [Subtask Time Tracking](api-subtask-time-tracking-procedures.markdown)
- [Task Files](api-task-file-procedures.markdown)
- [Project Files](api-project-file-procedures.markdown)
- [Links](api-link-procedures.markdown)
diff --git a/doc/api-subtask-time-tracking-procedures.markdown b/doc/api-subtask-time-tracking-procedures.markdown
new file mode 100644
index 00000000..67447623
--- /dev/null
+++ b/doc/api-subtask-time-tracking-procedures.markdown
@@ -0,0 +1,102 @@
+Subtask Time Tracking API procedures
+====================================
+
+## hasSubtaskTimer
+
+- Purpose: **Check if a timer is started for the given subtask and user**
+- Parameters:
+ - **subtask_id** (integer, required)
+ - **user_id** (integer, optional)
+- Result on success: **true**
+- Result on failure: **false**
+
+Request example:
+
+```json
+{"jsonrpc":"2.0","method":"hasSubtaskTimer","id":1786995697,"params":[2,4]}
+```
+
+Response example:
+
+```json
+{
+ "jsonrpc": "2.0",
+ "result": true,
+ "id": 1786995697
+}
+```
+
+## setSubtaskStartTime
+
+- Purpose: **Start subtask timer for a user**
+- Parameters:
+ - **subtask_id** (integer, required)
+ - **user_id** (integer, optional)
+- Result on success: **true**
+- Result on failure: **false**
+
+Request example:
+
+```json
+{"jsonrpc":"2.0","method":"setSubtaskStartTime","id":1168991769,"params":[2,4]}
+```
+
+Response example:
+
+```json
+{
+ "jsonrpc": "2.0",
+ "result": true,
+ "id": 1168991769
+}
+```
+
+## setSubtaskEndTime
+
+- Purpose: **Stop subtask timer for a user**
+- Parameters:
+ - **subtask_id** (integer, required)
+ - **user_id** (integer, optional)
+- Result on success: **true**
+- Result on failure: **false**
+
+Request example:
+
+```json
+{"jsonrpc":"2.0","method":"setSubtaskEndTime","id":1026607603,"params":[2,4]}
+```
+
+Response example:
+
+```json
+{
+ "jsonrpc": "2.0",
+ "result": true,
+ "id": 1026607603
+}
+```
+
+## getSubtaskTimeSpent
+
+- Purpose: **Get time spent on a subtask for a user**
+- Parameters:
+ - **subtask_id** (integer, required)
+ - **user_id** (integer, optional)
+- Result on success: **number of hours**
+- Result on failure: **false**
+
+Request example:
+
+```json
+{"jsonrpc":"2.0","method":"getSubtaskTimeSpent","id":738527378,"params":[2,4]}
+```
+
+Response example:
+
+```json
+{
+ "jsonrpc": "2.0",
+ "result": 1.5,
+ "id": 738527378
+}
+```
diff --git a/tests/integration/BaseProcedureTest.php b/tests/integration/BaseProcedureTest.php
index e3382e82..beb13ff7 100644
--- a/tests/integration/BaseProcedureTest.php
+++ b/tests/integration/BaseProcedureTest.php
@@ -17,6 +17,7 @@ abstract class BaseProcedureTest extends PHPUnit_Framework_TestCase
protected $projectId = 0;
protected $taskTitle = 'My task';
protected $taskId = 0;
+ protected $subtaskId = 0;
protected $groupName1 = 'My Group A';
protected $groupName2 = 'My Group B';
@@ -119,4 +120,14 @@ abstract class BaseProcedureTest extends PHPUnit_Framework_TestCase
$this->taskId = $this->app->createTask(array('title' => $this->taskTitle, 'project_id' => $this->projectId));
$this->assertNotFalse($this->taskId);
}
+
+ public function assertCreateSubtask()
+ {
+ $this->subtaskId = $this->app->createSubtask(array(
+ 'task_id' => $this->taskId,
+ 'title' => 'subtask #1',
+ ));
+
+ $this->assertNotFalse($this->subtaskId);
+ }
}
diff --git a/tests/integration/SubtaskProcedureTest.php b/tests/integration/SubtaskProcedureTest.php
index 7ab4ef0b..b9868e6f 100644
--- a/tests/integration/SubtaskProcedureTest.php
+++ b/tests/integration/SubtaskProcedureTest.php
@@ -5,7 +5,6 @@ require_once __DIR__.'/BaseProcedureTest.php';
class SubtaskProcedureTest extends BaseProcedureTest
{
protected $projectName = 'My project to test subtasks';
- private $subtaskId = 0;
public function testAll()
{
@@ -18,16 +17,6 @@ class SubtaskProcedureTest extends BaseProcedureTest
$this->assertRemoveSubtask();
}
- public function assertCreateSubtask()
- {
- $this->subtaskId = $this->app->createSubtask(array(
- 'task_id' => $this->taskId,
- 'title' => 'subtask #1',
- ));
-
- $this->assertNotFalse($this->subtaskId);
- }
-
public function assertGetSubtask()
{
$subtask = $this->app->getSubtask($this->subtaskId);
diff --git a/tests/integration/SubtaskTimeTrackingProcedureTest.php b/tests/integration/SubtaskTimeTrackingProcedureTest.php
new file mode 100644
index 00000000..6c45c983
--- /dev/null
+++ b/tests/integration/SubtaskTimeTrackingProcedureTest.php
@@ -0,0 +1,46 @@
+<?php
+
+require_once __DIR__.'/BaseProcedureTest.php';
+
+class SubtaskTimeTrackingProcedureTest extends BaseProcedureTest
+{
+ protected $projectName = 'My project to test subtask time tracking';
+
+ public function testAll()
+ {
+ $this->assertCreateTeamProject();
+ $this->assertCreateTask();
+ $this->assertCreateSubtask();
+ $this->assertHasNoTimer();
+ $this->assertStartTimer();
+ $this->assertHasTimer();
+ $this->assertStopTimer();
+ $this->assertHasNoTimer();
+ $this->assertGetSubtaskTimeSpent();
+ }
+
+ public function assertHasNoTimer()
+ {
+ $this->assertFalse($this->app->hasSubtaskTimer($this->subtaskId, $this->userUserId));
+ }
+
+ public function assertHasTimer()
+ {
+ $this->assertTrue($this->app->hasSubtaskTimer($this->subtaskId, $this->userUserId));
+ }
+
+ public function assertStartTimer()
+ {
+ $this->assertTrue($this->app->setSubtaskStartTime($this->subtaskId, $this->userUserId));
+ }
+
+ public function assertStopTimer()
+ {
+ $this->assertTrue($this->app->setSubtaskEndTime($this->subtaskId, $this->userUserId));
+ }
+
+ public function assertGetSubtaskTimeSpent()
+ {
+ $this->assertEquals(0, $this->app->getSubtaskTimeSpent($this->subtaskId, $this->userUserId));
+ }
+}